Why Most Unit Testing is Waste
Brian reposts Why Most Unit Testing is Waste by James O Coplien
Note the word “Most” in the title. The article does seem to argue against unit tests except in certain contexts but seems to mostly describe bad unit tests.
I think there is a place for unit tests but they should not be relied on as much as they are, and they shouldn’t be mandated in all circumstances.
I believe writing and maintaining unit tests can be a much bigger effort than the code they are written to test so the return on investment may make them prohibitive when other types of testing can be sufficient for the amount of effort required.
Excerpts:
Be humble about what tests can achieve. Tests don’t improve quality: developers do.
Software engineering research has shown that the most cost-effective places to remove bugs are during the transition from analysis to design, in design itself, and in the disciplines of coding. It’s much easier to avoid putting bugs in than to take them out.
Developers should be integrating continuously and doing system testing continuously rather than focusing on their unit tests and postponing integration, even by an hour.
For the type of mobile apps I write, with background asynchronous data fetches and event driven flow, I’ve only experienced one solution that worked well and that was a QA team that was well versed with Appium and was able to get a high level of automated regression test coverage in our Android AND iOS application. There was only a small amount of special coding I had to add to make their job easier such as setting the contentDescription value for a custom view so the value of the view could be determined.
Update: Oct 25, 2021: Code Coverage Best Practices