I would suggest looking at things a little differently. Adding new unit test code to an existing application without incident might not give you the best results. If you are doing this to get familiar with the code base or you truly have time to kill and want to test out test generators then ignore my comments.
To be pragmatic, you should look through all the bug lists. Then create unit tests for each of the bugs, resulting in how it should of behaved. Ideally, you would only add new code for each bug as you reach it.
Times to add unit test code:
- Adding new functionality
- Re-factored code
- Fixed a bug
- Learning what the code does
- Prove a bug exists
It is difficult to quantify the value of adding unit tests after the fact.
I normally don't allow myself to write answers that are against what the asker wants, but I feel this is a good lesson to pass along.
I want to introduce the concept of unit tests (and testing in general) to my co-workers
I think it might be better to start from the practical, not the conceptual, side. Of course, if you find during casual discussion that your coworkers and/or management are interested to hear about unit testing, all the better - then you may google up some concrete experiences / evidence from the web, put together a brief training, etc. However, from what you describe, it sounds like your teammates aren't very open to this strange new idea.
In such a situation, I would just start writing my little unit tests without trying to explain too much to anyone first. Add a couple of them whenever I change code, without trying to thoroughly cover all the code (which would take an inordinate amount of time). Ideally, if I manage to strike a fine balance, by the time they notice I am writing unit tests, I may already have a substantial test suite, and some concrete results to show (like "with this test case I managed to catch a bug introduced by last week's change, which would have otherwise slipped through to QA/production"). That will prove the tests' worth to any serious developer.
After that, I am in a good position to start explaining the long term benefits of unit testing, like
- it proves that the code works - anytime, anywhere, instantly and automatically, which in turn
- gives confidence to refactor, resulting in improved design and better maintainability,
- and if something gets broken, unit tests give you (almost) instant feedback, as opposed to several days' or weeks' latency if the bug is caught by a separate QA department. Which usually enables you to fix the bug in seconds, instead of debugging for hours/days, in code which has long since dropped from your short term memory.
See also this related thread: Automated unit testing, integration testing or acceptance testing.
And an earlier one from SO: What is unit testing?
Best Answer
Wow, this describes a recent situation of mine exactly on a large, existing project. No unit tests at all, and reluctance toward/skepticism of the idea. At the time of writing, I've been able to work with another person who favored it to get it more accepted (though he and I are largely the only ones that generally write tests). The code base was (still is) heavily laden with procedural static code, but it's getting better. Here are some of the things that I did to improve the situation:
These are ways to make your code more testable (and, I would argue, better in general), but selling the process to others is a different matter. I would offer the following advice for that: