I have found that good unit tests typically result in much higher quality code, which is why I try to do them whenever possible.
Unfortunately I have also found that writing high quality unit tests typically takes considerbly longer than writing the actual application code. Furthermore, although I can frequently nail a function I’m writing for an application in the first pass, my unit test functions may have to be updated as much as ten or even twenty times before they actually work.
This is because writing good tests is frequently much more complicated than writing good code, particularly if you are a good developer.
In test code you have to not only have working application code, you also have to figure out a priori how to set up the inputs and validate the outputs of the function you want to test. In the case of persistent storage, which is something I’m working on now, this can be highly nontrivial to do. In the last go around I have easily spent at least 80 percent of my time debugging my test code.
Filed under: JIVA by Administrator