There is no reason in scripture to believe these passages do not mean what they say. Or that God is just saying it like this to relate to us and does not mean it.
Deut 8:2-And you shall remember all the way which the LORD your God has led you these forty years in the wilderness, that he might humble you, **testing you** ** to know ** what was in your heart, whether you would keep his commandments, or not.
Gen 22:1-Now it came to pass after these things that God **tested** Abraham, and said to him, “Abraham!” And he said, “Here I am.”
Gen 22:12-And He said, “Do not lay your hand on the lad, or do anything to him; for now **I know** that you fear God, since you have not withheld your son, your only son, from Me.”
Exod 16:4-Then the LORD said to Moses, “Behold, I will rain bread from heaven for you. And the people shall go out and gather a certain quota every day, that I may **test them,** whether they will walk in My law or not.
Exod 20:20-And Moses said to the people, “Do not fear; for God has come to **test you,** and that His fear may be before you, so that you may not sin.”
Deut 13:3-”you shall not listen to the words of that prophet or that dreamer of dreams, for the LORD your God is **testing you** ** to know* whether you love the LORD your God with all your heart and with all your soul.
Judges 2:22-”so that through them I may **test Israel,** whether they will keep the ways of the LORD, to walk in them as their fathers kept them, or not.”
Judges 3:4-And they were left, that He might **test Israel** by them, **to know** whether they would obey the commandments of the LORD,which He had commanded their fathers by the hand of Moses.
2 Chr 32:31-But when envoys were sent by the rulers of Babylon to ask him about the miraculous sign that had occurred in the land, God left him to **test him** and **to know** everything that was in his heart.’
source: facebook (link).