A selection of verses showing how this theme runs consistently through the Bible.
God tells Moses that he is testing the early Israelites when they encounter problems. He wants to see if they will continue to obey him:
2 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, to test you, to know what was in your heart, whether you would keep his commandments or not. 3 He humbled you, allowed you to be hungry, and fed you with manna, which you didn’t know, neither did your fathers know, that he might teach you that man does not live by bread only, but man lives by every word that proceeds out of the LORD’s mouth.
God is testing king Hezekiah when princes from Babylon come to him:
31 However concerning the ambassadors of the princes of Babylon, who sent to him to enquire of the wonder that was done in the land, God left him, to try him, that he might know all that was in his heart.
James tells us to appreciate that trials can be good for us:
2 Count it all joy, my brothers, when you fall into various temptations, 3 knowing that the testing of your faith produces endurance. 4 Let endurance have its perfect work, that you may be perfect and complete, lacking in nothing.
The apostle Peter encourages us to continue faithful despite difficult times to come:
6 Wherein you greatly rejoice, though now for a little while, if need be, you have been grieved in various trials, 7 that the proof of your faith, which is more precious than gold that perishes even though it is tested by fire, may be found to result in praise, glory, and honour at the revelation of Jesus Christ—
He also warns us to expect trials in our lives:
12 Beloved, don’t be astonished at the fiery trial which has come upon you to test you, as though a strange thing happened to you.