|
Re: What are Your JUnit Pain Points, Really?
|
Posted: Oct 28, 2009 1:14 PM
|
|
> Are you, in effect, saying that unit testing is overly > emphasized, and at the expense of other forms of testing?
Exactly. Unit testing, in the strictest sense of the term, is rather good at finding bugs in the sort of self-contained code that is typically used to implement algorithms and data structures. I'd wager, however, that very few modern programmers spend much time on that sort of code any more, since most of that functionality is now provided by off-the-shelf components. (e.g., HashMap, ArrayList, RDBMS, etc.)
Speaking for myself, most of my time is spent connecting together multiple non-deterministic and lightly documented systems. (For example, creating a web app that connects humans to a legacy document management system.) Most of the bugs that crop up result from when the systems combine in unique and unexpected ways.
You could try to isolate each individual variable that contributed to the bug and then unit test each variable independently, but it's usually more fruitful to create a regression test reproduces the whole interaction. First, it tends to be 10x less work and just as effective. Second, future development will likely add, change, and remove variables in the interaction. When that happens and you have a bunch of small unit tests, you will need to update and re-validate a bunch of small unit tests, with no guarantee that the interaction as a whole will succeed as a result.
|
|