"Alif Lam Mim. Do people think that they will be left alone because they say: "We believe," and will not be tested. And We indeed tested those who were before them. And Allah will certainly make (it) known (the truth of) those who are true, and will certainly make (it) known (the falsehood of) those who are liars, (although Allah knows all that before putting them to test). Or those who do evil deeds think that they can outstrip Us (i.e. escape Our Punishment)? Evil is that which they judge! Whoever hopes for the Meeting with Allah, then Allah's Term is surely coming. And He is the All-Hearer, the All-Knower. And whosoever strives, he strives only for himself. Verily, Allah is free of all wants from the 'Alamin (mankind, jinns, and all that exists). Those who believe [in the Oneness of Allah (Monotheism) and in Messenger Muhammad, and do not apostate because of the harm they receive from the polytheists], and do righteous good deeds, surely, We shall remit from them their evil deeds and shall reward them according to the best of that which they used to do. And We have enjoined on man to be good and dutiful to his parents, but if they strive to make you join with Me (in worship) anything (as a partner) of which you have no knowledge, then obey them not. Unto Me is your return, and I shall tell you what you used to do. And for those who believe (in the Oneness of Allah and other items of Faith) and do righteous good deeds, surely, We shall make them enter in (the entrance of) the righteous (i.e. in
Paradise). Of mankind are some who say: "We believe in Allah," but if they are made to suffer for the sake of Allah, they consider the trial of mankind as Allah's punishment, and if victory comes from your Lord, (the hypocrites) will say: "Verily! We were with you (helping you)." Is not Allah Best Aware of what is in the breast of the 'Alamin (mankind and jinns). Verily, Allah knows those who believe, and verily, He knows the hypocrites [i.e. Allah will test the people with good and hard days to discriminate the good from the wicked (although Allah knows all that before putting them to test)]."
(AI-'Ankabut, 29 : 1-11).Read it’s explanation (Tafsir) from here.