All perfect praise be to Allaah, The Lord of the worlds. I testify that there is none worthy of worship except Him, and that Muhammad, sallallaahu ‘alayhi wa sallam, is His slave and Messenger.
‘Uthmaan narrated that whenever the Prophet wrapped up a burial, he used to stand before the grave and order the Companions to supplicate to Allaah The Almighty for the forgiveness of the deceased and his steadfastness, because he was being put to test at that time. [Abu Daawood and Al-Haakim, Saheeh]
It is also reported that the dead person benefits from the prayers of the living and that the slave will be tried and questioned in his grave. In a well-known Hadeeth on the authority of Al-Baraa' ibn ‘Aazib the Prophet and his Companions were once sitting around a grave, when he ordered them twice or thrice to seek refuge with Allaah The Almighty from the punishment of the grave. Then, he began describing the state of the souls of the believers and disbelievers when they are taken out of the body, as well as what befalls each of them, when the souls are returned.
He mentioned that two angels will come to the believer, make him sit up and ask: “Who is your Lord? What is your religion? And, what was that man who was appointed to you?” [The believer] will reply: “My Lord is Allaah The Almighty; my religion is Islam and the man sent to me was the Messenger of Allaah.” They will ask: “How do you know this?” He will respond: “I read the Book of Allaah, believed in it and accepted it as the truth.” Then, a caller will proclaim from the heaven: “My servant has spoken the truth; so spread out a heavenly bed for him and open a door for him to Paradise, in order that some of its air and perfume will reach him.” His grave will then be widened for him as far as the eye can see. Subsequently, his good deeds will appear to him in the shape of a bright-faced, elegantly-clothed and well-scented man, and he will bring him glad tidings that will please him and tell him that this is the day he was promised. Upon hearing this, the deceased will say, "O my Lord! Make the Hour come [fast]; make [it] arrive, so that I may return to my family and property.”
Then, the Prophet mentioned the disbeliever and his experience. He will be asked the same questions [mentioned above], to which he will reply: “Huh, huh! I do not know.” Then, a caller will call out from heaven: “My servant has lied, so prepare a bed of fire for him, and open a door for him to Hell, so that some of its heat and poisonous wind will come to him.” The dead person’s grave will then be compressed, so that his ribs will be crushed together. Then, his evil deeds will appear to him in the shape of an ill-dressed and foul-smelling man, who will bring him bad news, which will grieve him; he will then be told that this is the day he was promised. Upon hearing that, the person [in the grave] will say: "My Lord! Do not make [the final] Hour come.” [Ahmad]
This is the trial and test that will take place in the grave. We implore Allaah The Almighty to keep us steadfast in the worldly life and in the Hereafter.
Allaah Knows best.