In order to satisfy customers with your product, you want to make sure that your shipped software reaches a maximum level of quality.
Unit testing is an efficient way to achieve this software quality. However, creating and maintaining unit tests also costs a lot of time (and thus money). That is why people often talk about a trade-off between money spent on unit testing, and software quality. The more you save on unit testing, the worse your quality.
The good news: this is not necessarily true. If you stick to the rules presented in this article, you can save money on unit testing, without cutting down on the quality of your developed software!
1 Define only the most important test cases
A lot of time is wasted on creating unit tests which are redundant or do not allow to find any actual bug. So you can save a lot of time by only defining those tests which are most likely to find bugs. And also only define one test for each potential bug. To do so, you can apply techniques like equivalence class partitioning, as described in this article: 2 Methods that help you save 60 % of your effort in Unit Testing
2 Get rid of bad unit tests
Even if you apply modern best practices for only creating inportant test cases, they might become outdated or irrelevant after some time. This is why you have to regularly check for bad unit tests. How can you do that? I’ve described this in 5 bulletpoints here: 5 Bulletpoints how to spot Bad Unit-Tests
3 Minimize the time you spend on each unit test
Once you have made sure that you only have the most meaningful unit tests in your test suite, you still have to spend a lot of time on each test case to (i) keep it up to date while the underlying software evolves, and (ii) go through it once it fails, in order to find out the nature of this failure (a bug in your software, or an outdated testcase). To make this as easy as possible, you have to reduce the time you need to spend on understanding what’s going on in your test code.
This makes it fast and easy to
(i) perform changes, and
(ii) perform debugging, without losing any quality in the final software.
But how can you make these tasks easier? Again, there is a whole list of best practices on clean code for your unit tests. I’ve compiled my personal highlights, from the AAA pattern to naming best practices, in the following article: Clean Unit-Testing – die Kunst, wartbare Unit-Tests zu schreiben
Apply the three rules in this article today, and start reducing your unit testing effort without losing any quality in your final product! And let me know about your experiences in the comments section below!
Image by vectorjuice on Freepik
When you visit any web site, it may store or retrieve information on your browser, mostly in the form of cookies. Control your personal Cookie Services here.