"I also will no longer drive out before them any of the nations which Joshua left when he died, 22in order to test Israel by them, whether they will keep the way of the Lord to walk in it as their fathers did, or not," (Judges 2:21-22).
God routinely tests people but not so He will learn what they will actually do because God knows all things (1 John 3:20). Instead, it is for the strengthening and purification of the faith of God's people, so they might learn and grow through the test. Furthermore, God speaks to people in discovery terms, so they might hear and know that God "now will use them" according to His purpose. Testing verses are also related to God's anthropomorphic expression where God speaks in human terms and in human ways as He reveals Himself to and through people.
Here, God is allowing the testing to provide an opportunity for the Israelites to prove themselves before God. Judges 3:1-2 says, "Now these are the nations which the Lord left, to test Israel by them (that is, all who had not experienced any of the wars of Canaan; 2only in order that the generations of the sons of Israel might be taught war, those who had not experienced it formerly)."