Although no software can run reliably without proper testing, software testing is also responsible for a considerable share of money spent in software development projects. Why? Because developers are expensive – so the more time a developer has to spend on a task, the more expensive it will get. However, especially automated software tests that are usually written in software code are those who prove very efficient because they can be executed repeatedly once they are written. Unfortunately, they have to be written by developers most of the time, which makes automated tests also very expensive. Luckily, expecially when it comes to unit testing, most of the effort (and thus costs) ca be avoided if you do unit testing right.
In this article, I’ll show you the 3 keys to do so.
1Apply Clean Unit Testing Best Practices to minimize maintenance effort
The main effort lies in maintianing your test cases. After each change in the software, several tests might need to be adapted. To keep this effort as small as possible, you have to do the following.
A) Minimize the number of test cases that need adaptation.
B) Make sure that you can easily understand your test code, and see where it needs to be adapted.
The key in both cases is readability. Luckily, there are already best practices available that make it easy for you create unit tests that are as readable as possible. They start at defining only those test cases that actually provide value, go through finding the best names for your test methods, all the way to writing clean and structured unit test code. I’ve collected the most important patterns for you in this article Clean Unit-Testing – die Kunst, wartbare Unit-Tests zu schreiben
2Automate as much as possible
By applying clean code best practices, you can drastically reduce the time required for maintenance. If you want to go one step further though, you should also start automating as many steps as possible for maintaining your unit tests. This starts with using a continuous integration build that saves you the trouble of clicking a button, to creating a nightly build that lets you get an overview of your failed test cases during your first coffee in the morning, to ultimately start using the right tools for managing your test code that help you automatically stick to the clean unt testing best practices by creating test code for you (read more about the latter in the following post Supercharge Your Unit Tests with devmate).
3Delete unnecessary unit tests
Each unit test will cost a certain amount of time that you will need to spend on it in order to keep it up to date (even after applying step 1 of this article). Additionally, the more tests you have to run, the longer it might take for your test suite to finish – finally time to get that next cup of coffee after all. So to minimize the cost in terms of time spent for unit testing overall, you should make sure to keep your test suite as small as possible. Having no tests at all would obviously reduce the cost of unit testing to zero, but also does not lead to your desired result (because it will let your after-release quickfix development effort explode). So in the end, what you should make sure is to keep just the right amount of unit tests, regularly checking your test suite for bad unit tests (read more about this topic here 5 Bulletpoints how to spot Bad Unit-Tests).
But how can you find out which tests to keep and which ones to delete because they started to become unnecessary? Luckily, there is some guidance on this already in the following articles How to evaluate the value of your test suite.
So these are my top three keys to reduce the cost of unit testing in your development projects. How did they help you improve your testing process so far? Do you have more points to add to this list? I am looking forward to reading your comments!
Image by macrovector 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.