Thou hast proved mine heart,.... This properly belongs to God, who is the searcher of the heart and reins, and is desired by all good men; and though God has no need to make use of any means to know the heart, and what is in it; yet in order to know, or rather to make known, what is in the hearts of his people, he proves them sometimes by adversity, as he did Abraham and Job, and sometimes by prosperity, by mercies given forth in a wonderful way, as to the Israelites in the wilderness, De 8:2; sometimes by suffering false prophets and false teachers to be among them, De 13:3; and sometimes by leaving corruptions in them, and them to their corruptions, as he left the Canaanites in the land, and as he left Hezekiah to his own heart, Jud 2:22.
In one or other or more of these ways God proved the heart of David, and found him to be a man after his own heart; and in the first of these ways he proved Christ, who was found faithful to him that appointed him, and was a man approved of God;thou hast visited [me] in the night; God visited and redeemed his people in the night of Jewish darkness; he visits and calls them by his grace in the night of unregeneracy; and so he visits with his gracious presence in the night of desertion; and he often visits by granting counsel, comfort, and support, in the night of affliction, which seems to be intended here; thus he visited the human nature of Christ in the midst of his sorrows and sufferings, when it was the Jews' hour and power of darkness.