Here he excuses himself in two ways for asking to be tried. First from his thought, because he thinks of God's mercy, when he says, "Because your mercy is before my eyes"; as if to say, I ask to be tried because I trust in your mercy, which always provides a way out with the temptation: Is. 63: "I will remember the mercies of the Lord, the praise of the Lord for all the things the Lord has rendered to me." Likewise from the love of justice. "And I have been well pleased in your truth," that is, if you punish me for my sins, it pleases me; if I am tried, I know that you will reward me.
Source: Exposition on the Psalms of David