Currently, I am trying to get a motorbike license. I have prayed very hard and went for the test, but I failed three times. I feel so demoralized. All my friends, who are non-Christians, had passed but I couldn't. I asked God why at times. And I have even doubted Him, which was so wrong. The problem is that when we have expectations that someone will do this for us, but that particular expectation has not been fulfilled, doubts and unbelief starts to arise. How do I overcome this problem?
"You ask and do not receive, because you ask amiss, that you may spend it on your pleasures" (James 4:3).
Where does God promise to take tests for you? You failed your test three times because you didn't know enough to pass the written part of the test or you didn't do well on the driving portion. This isn't about God, it is about you. Your friends passed because they demonstrated the knowledge and skills needed to be given a license. You are right when you said that it was your expectations which got in your way of faith in God. I suspect it is also getting in your way of doing the best that you can do. You can pass this test, but you've been lazy about it because you figured God would take care of it.
In a sense, you are acting like the Israelites did in the days of Eli. They were losing their battles against the Philistines. Rather than seeing that God wasn't supporting them because of their sins, they thought they could force God to help by carrying the Ark of the Covenant into battle. They lost and they lost the Ark. No one can make God do as they please; it is simply the wrong attitude. "Surely you have things turned around! Shall the potter be esteemed as the clay; for shall the thing made say of him who made it, "He did not make me"? Or shall the thing formed say of him who formed it, "He has no understanding"?" (Isaiah 29:16).
Look at why you failed to pass, and then fix the problem. If it is knowledge, study the material the government gives you and have friends quiz you on it. If it is in the driving skills, go to a driving school and learn the proper techniques. Do the best that you can, then you can properly lean on God to take care of the things that are out of your hands.