D E V M A T E

Loading

Unit testing is one of the most annoying tasks in every software engineering project. On the other side, it’s also the most efficient way to ensure the quality of your created software. However, there are still many ways to reduce the time you have to spend on your unit tests, but still get the same output. In this article, I’ll show you the 2 most important rules that you should stick to to approach your unit tests in a more pragmatic way:

1Automate as much as possible

The first rule is kind of obvious: The more you automate, the less you have to do yourself. Sounds pragmatic – but how can you automate unit testing? Well you can start with automatically generating test code for your defined unit tests. Modern unit testing tools allow you to use some high-level method to define test cases (e.g. equivalence class partitioning: 2 Methods that help you save 60 % of your effort in Unit Testing) and derive the corresponding code automatically (read more here: Supercharge Your Unit Tests with devmate)

But also executing your unit tests should be automated. I mean most IDEs already allow you to execute targeted test suites with the click of a button. But with nightly builds and continuous integration builds, you can take the next step here. These automated test executions allow you to continuously get feedback on your software quality, without the need to think about actually executing unit tests.

2Structure is king

Most time is in unit testing is spent on understanding the tests you have written. Once a test fails, you have to dig into the code again to localize the defect. Every time your requirements change, you have to understand the implications on the existing unit tests, and adapt them accordingly. Thus, the most pragmatic way to approach this is to structure your unit tests in a way that you can reproduce them as fast as possible, based on their name and the written code.

The good news here: there are some practical patterns that you can apply to apply a good structure to your unit tests

Once you apply these two rules in your projects, you should notice that you start spending way less time on unit testing, and more time on actually implementing functionality of your software.

Image by syarifahbrit on Freepik

Leave a Comment

We use cookies to give you the best online experience. By agreeing you accept the use of cookies in accordance with our cookie policy.

Privacy Settings saved!
Privacy Settings

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.

GetResponse, Google Analytics

We use LinkedIn Insight for marketing purposes. You can disable these cookies.

We use Google Analytics for marketing purposes. You can disable these cookies.
  • __utmz
  • __utma
  • _ga
  • _gat

We use GetResponse for marketing purposes. This service cannot be disabled, otherwise the website functions will be limited.

Decline all Services
Accept all Services
Get Free Access Now to
9 eBooks!
All about Automated Software Testing
Proven experts
Learn to save up to 75% of your test efforts
Get Free Access Now!
Get Access Now! & Save 50%
Personal Trainer FREE Nutrition Custom Workout App
Get Access Now!
eBook Download
Enter your details to get your free ebook!
All about Automated Software Testing
Download Free Ebook
SUBSCRIBE
MY WEB
NEWSLETTERS
Lorem ipsum dolor sit amet, consectetur adipiscing