This is the big question : how much ?
Cheap people only calculate cost with money. But if you want well-tested software you’ve got to see the bigger picture.
Unit tests are like painting. A good artist knows what he wants and when he has it. He also knows the “why”. Same for (good) developers/managers.
Writing unit test? but don’t know if you covered everything? Here is a simply good unit test checklist.
Here are a few items I try to respect every time I write unit tests. It’s a solid and good unit test checklist. At least good for most of my code 🙂
Edit: a more extended and detailed list I wrote for DZone.
- My test class is testing one and only one class
- My methods are testing one and only one method at a time
- My variables and methods names are explicit
- My test cases are easy to read by human
- My tests are also testing expected exception with
- My tests don’t need access to database
- My tests don’t need access to network resources
- My tests respect the usual clean code standards (length of lines, cyclomatic complexity,…)
- My tests control side effects, limit values (max, min) and null variables (even if it throws an exception)
- My tests can be run any time on any place without needing configuration
- My tests are concrete (ex. dates are hardwired, not computed every time, strings too…)
- My tests use mock to simulate/stub complex class structure or methods
Maybe you’ve already done a great deal by appointing a Test Supervisor that checks every aspect of the finished product. That’s terrific. Congratulations.
But there are still bugs ? Your team is telling you that this little change you asked took the all system down ? How comes ?
For more details about unit tests, see my series: Test Culture Episode 1. The 101 Unit Testing Guide For Busy Managers.
As a manager you love metrics. Code coverage is a good metric. But a very limited one. Don’t be naive : a 100% code coverage is impossible and not enough to ensure quality. You must do more.
« If you don’t have unit tests, you are not refactoring, you are just moving shit around »
I’m so sorry. I could not find the source of this quote. But you get the meaning anyways. Or maybe not… Maybe you just think that unit tests are optional and refactoring is even more optional.
No. You can’t !
As a manager the only bossy instruction you should give is :
“Don’t you ever shut down a crashing test ! Fix it now !”
Unit tests are uselesss if they are not launched often, automatically and do some noise when crashing !
Let me illustrate the importance of unit testing with a budget / motivation nightmare we lived in one of my job.