“You have tried my heart, you have visited me by night, you have tested me, and you will find nothing; I have purposed that my mouth will not transgress. With regard to the works of man, by the word of your lips I have avoided the ways of the violent. My steps have held fast to your paths; my feet have not slipped.” -Psalm 17:3–5
David is not claiming sinless perfection. Nor is he denying the universal sinfulness of mankind. He is proclaiming his integrity. Just as he makes three requests for God to pay attention to him and his situation in verses 1-2 (i.e., hear, attend, give ear), he attests to God’s three-fold probing (i.e., tried, visited, tested) in verse 3 and is confident that He will find nothing.
How is David so sure?
Because he can honestly say he has purposed (or resolved) not to sin with his mouth; he has avoided the company and philosophy of violent men; and he has adhered to God’s law without slipping (literally, without moving away from it). Again, we need to keep in mind David is not exaggerating his goodness or dismissing his own sinful nature. The context is in terms of his integrity toward God and toward the others over whom he seeks vindication. He is not perfect, but he knows his piety is without pretense.
Consider John’s first epistle in the New Testament: “Little children, let us not love in word or talk but in deed and in truth. By this we shall know that we are of the truth and reassure our heart before him; for whenever our heart condemns us, God is greater than our heart, and he knows everything. Beloved, if our heart does not condemn us, we have confidence before God;” -1 John 3:18–21