Even if they are at the basis of the software testing pyramid and they are at the heart of the Test-Driven Development (TDD) approach, unit tests are still a controversial topic in software development and some people event consider that most unit testing is waste. In his blog post, Bas Dijkstra explains why he thinks that unit testing should be the basis of any solid automation strategy.
Bas Dijkstra starts by explaining that unit tests are easy to write and fast to run, the opposite of integration or end-to-end (E2E) tests. Unit tests have also a positive influence on code. If you want to improve the testability of your code, you need to improve its structure. This virtuous circle means also that when you write clean code, it is easier to write tests for it. Finally, unit tests are the basis for integration tests and refactoring. When your code enter a maintenance phase, having unit tests acts as a safety net that should make sure your changes are not breaking individual functionalities.
His conclusion is that “In the end, unit tests can, will and need not replace integration and end-to-end tests, of course. There’s a reason all of them are featured in the test automation pyramid. But when you’re trying to create or improve your test automation strategy, I’d advise you to start with the basis and get your unit testing in place.”
Read the complete blog post on https://www.ontestautomation.com/why-i-think-unit-testing-is-the-basis-of-any-solid-automation-strategy/