God permits some wars or situations to come your way so that they can teach you how to fight (Psalm 18:34)
Judges 3:1-4 (NIV) says;
"These are the nations the Lord left to test all those Israelites who had not experienced any of the wars in Canaan 2 (he did this only to teach warfare to the descendants of the Israelites who had not had previous battle experience): 3 the five rulers of the Philistines, all the Canaanites, the Sidonians, and the Hivites living in the Lebanon mountains from Mount Baal Hermon to Lebo Hamath. 4 They were left to test the Israelites to see whether they would obey the Lord’s commands, which he had given their ancestors through Moses"