Significance of Testing

Learn about the importance of testing and the way it solves common problems in the development world.

Now that you have a basic idea of testing, let’s explore why testing is so important when developing a production application.

It is easy to overlook the role of testing when starting a new project. While it is relatively small, it is quite easy (and sometimes faster) to test it manually. However, as the project grows, manual testing becomes infeasible.

The power of knowing

Testing gives you the power of knowing. With a comprehensive test suite in place, you can instantly check if your changes broke anything else in the app.

How many times did you refactor a piece of code and then found out that something completely unrelated stopped working? Or how many times have you read through thousands of lines of code to find out which modules use this particular function?

Testing makes refactoring a piece of cake. You can change anything without fearing that the change will result in unwanted consequences. This will accelerate the development process immensely. Suddenly, the refactoring efforts are kept to a minimum and the backlog will be cleared before you know it.

Code cleanliness

While writing code without tests, the design specifications are translated directly to the production code. When following TDD, there is an intermediate step. You first translate the specifications into tests, and write production code to follow the tests.

widget

This gives your production code structure that would not manifest itself any other way. Suddenly, your production code has to service not just customers, but you as well. Answering complex questions about how the code operates, onboarding new staff, and adding new features are some of the aspects that will gradually become harder without a rigid structure. While writing testable code, you ensure it is programmatically usable, and this dictates certain principles. For example, it will be impossible to test a 500-line function that does everything, so testing will force you to keep your code distributed and unitized.

Documentation

Lastly, one more (not so obvious) advantage of having a comprehensive test suite is that it can play the role of documentation.

When you develop a certain module, you will write tests that cover every possible use case for this module. It follows then, that any developer who wants to use said module can just open the relevant tests and see how this module is used.

Tests can be even more valuable than documentation since these are code samples that are:

  1. Designed to run perfectly
  2. Written by the relevant developer himself.

If you find a bug or encounter a use case that is not covered by existing tests then you will add to this documentation without any additional effort!

Quick recap

Testing has a few obvious and hidden advantages:

  • Quicker iteration and no refactoring blocks.
  • Improved code health and cleanliness.
  • Every single function and behaviour in your system is documented.