If he knows how we'll do in the test and he created us, whats the point of testing? I still don't understand. Why create a person who He'll know will fail in the first place? Or is it possible to 'surprise' God, thanks to the free will he gave us? But in that case He would not know beforehand how we'd perform, right? It's all a bit confusing, but I suppose it's probably a mistake to try and apply logic on God.
Like brother Habeshi explained, it's a test for us (and we don't know the results), the test is not for Allaah.
Maybe I should take a step back. Why did God create humans in the first place? What is our purpose? Does the Qu'ran explain that? Maybe that sheds some light on this as well?
Thanks

.
Allaah says in His final revelation (translation of the meaning of):
And I did not create the jinn and mankind except to worship Me. [Qur'an 51: 56]
We as Muslims believe that this life is temporary, we are created by Allaah, and yes - we are created to worship Him. But wait, worship doesn't just mean to continuously pray, fast, etc.
Worship in the Islamic context is anything which is loved by Allaah. So for example, if a guy gives food to his wife, he is fulfilling a duty which is loved by Allaah. Since you intended to draw closer to Allaah by feeding your wife, then that is an act of worship in of itself. Therefore, you would gain Allaah's pleasure, therefore be rewarded by Him inshaa Allaah (God willing.)
Similarly, all aspects of our life can be a means of drawing closer to our Creator, and Sustainer.
Along with these acts of worship, we are also obligated to thank Allaah for the good which He has bestowed upon us. We are obligated to worship Allaah (which includes the 5 daily prayers) - so that we remain firm upon the correct path. During each prayer, we recite to Allaah - "
Guide us to the Straight Path.." - if one stops praying to Allaah, they usually break their contact with Him due to the excessive distractions of this life. Therefore an obligation makes the believer firm upon keeping their duty to Allaah so they remain upon the correct straight path which leads to Him (The Siraat Al Mustaqeem.)
Therefore, if one asks why Allaah asks us to worship Him - the answer is so we remain aware of God, so we continue doing good to please Him and earn His pleasure, so we abstain from the evil which He has forbidden us from - which is harm in of itself, and that is why it is forbidden.
Those who abstain from evil and do good to please God draw closer to Him, and due to that - there reward is with Him. Whereas those who do evil harm their own selves, while they percieve it not, and distance themselves away from Allaah, their Creator and Provider, and His reward. Yet still, Allaah is willing to forgive them if they repent to Him sincerely, however once death overtakes a person - then that is the end, and it is too late to turn back after that. Since this life is the test, and the Day of Judgement is the Day of Recompense, and the Paradise is for the believers and doers of good, and the Hellfire is the abode for those who disbelieve and are ungrateful to Allaah.
And Allaah knows best.
Peace.