We often tend to have doubts about whether the Lord will accept our worship and save us. When misfortunes strike, our doubts become stronger. God tests us to see if we will continue to be loyal to Him, even when we are beset by problems, said M.V. Anantapadmanabhachariar. This is akin to a teacher testing a prospective student, before accepting him as a student. If a teacher does not test a student to see if he has the aptitude for a subject, then the teacher's efforts to instruct will be futile. A pupil must be made to go through rigorous tests, for the guru to be able to find out if he is worthy of instruction. Obedience and loyalty are qualities the student must have. A guru cannot accept anyone who comes to him. So the guru sets the student some tasks, and the student who carries out the tasks assigned to him, to the guru's satisfaction, is the one who will be taught by the teacher, or by the preceptor as the case may be.
Brahma failed to test Indra, when the latter came to Brahma for instruction. Because Brahma taught Brahma vidya to an undeserving student, Brahma forgot the Brahma vidya!
There is an excellent example of how saints test those who seek their guidance. A man once approached Ramakrishna Paramahamsa and said he wanted to dig a well. Ramakrishna told him where to dig the well. The man dug up to a depth of 15 feet and not finding water, he dug a little further away. When this effort too proved futile, he dug yet another well. He ended up digging four wells, but with nothing to show for his effort. He then complained to Ramakrishna, who asked him how many feet in all he had dug. The man replied that he had dug a total of 100 feet. Ramakrishna then said that if he had dug where Ramakrishna had pointed, and had dug there to a depth of 100 feet, he would have found water. Instead he had wasted his efforts. Had the man had faith in Ramakrishna, he would never have moved to another spot to dig, but would have continued to dig where the saint had asked him to dig. Thus it is that saints and gurus test the worthiness of those who come to them, before giving them spiritual guidance and advice.