When the error messages are caused, by a test suite with a mathematical rigourous spec and edge case geared tests, this eventually results in correct code.
And note that writing the complete and correct test suite is likely to be a task of similar difficulty to designing and writing good code! I'm not saying don't test, but I am saying that non-trivial testing is difficult.