Unit tests vs. Other tests
by Venkat Subramaniam
Trey, I will start by referring to what's said in Pragmatic Unit Testing - "Unit testing is done by programmers, for programmers."
I have come across developers who reject unit testing as some thing for the QA team to do. Recently I ran into a few QA folks who wanted to know how they can write unit tests instead of their programmers. I can't imagine the effectiveness of anyone but the programmer writing the unit tests.
Testing for functionality, behavior, correctness, performance, etc. is not optional and unit test does not replace those. Uncle Bob, et. al. say "Unit tests are necessary but insufficient as verification tools," in Agile Software Development, Principles, Practices and patterns. However, as againts what's
recommended in that book, I am not fully convinced that I would want (as a developer) to fully automate the acceptance testing. This is where, in my opinion, the QA folks may be better than me as a developer.
Generally speaking, I will have my QA team constantly test my product. I will hold weekly demo (or biweekly demo as the schedule may be) to get the user acceptance, input and feedback.
Unit tests, on the other hand are run more (much more) often. Each developer runs the unit tests on his/her own machine. Soon after the code is checked in, I run the tests on the build machine (using tools like cruise control). [Martin Fowler's article on Continuous Integration is a must read.] I can't imagine refactoring the code without these in place. [I strongly recommend looking at Mike Clark's Pragmatic Project Automation.]
Further, what about testing the UI? Well, if most of the logic is moved away from the UI (and it should be) then running automated tests is not as important on these. You can run these tests on the behavior instead of visual of the UI. Then you can rely on the QA and business customers to validate the UI for its usability, etc.
To me unit testing is exciting since it is more of an act of design and aids with refactoring. Being a programmer (who loves it), I tend to focus more on the white box testing. Thank God, I have had opportunity to work with some good QA folks who take care of the rest :) These are some general thoughts.
What are your thoughts?
Unit tests is must have...
its for programmers not for QA
|Tests gives confidence while refactoring. http://www.jsptube.com|