Software testing: The Secret Superpower

Tomas Svojanovsky
4 min readJul 26, 2023

--

Software is complex. No matter what language you use, what frameworks you build on, and how elegant your coding style is, it is hard to verify software correctness just by reading the code. That’s not only because non-trivial applications usually consist of large amounts of code. It is also because complete software is often composed of many layers and relies on many external or interchangeable components, such as operating systems, libraries, databases, caches, web APIs, or clients used to interact with your code (browsers, for instance).

Photo by Chivalry Creative on Unsplash

Every software developer understands that software failures may cause severe damage to businesses, people, or even society as a whole. It is common for programmers to take over a project without tests or with a poorly tested codebase. These projects do not end up well, or there must be someone who spends an enormous amount of time on testing. There should be a better option, right?

Why should I test?

  • Code tends to worsen over time. Each time you make a change in the code, there is a greater chance of making a mistake. Without proper care, such as constant cleaning and refactoring, the system becomes increasingly complex and disorganized
  • The goal of testing is to enable sustainable growth of the software project. Good tests helps avoid the stagnation phase and maintain the development pace over time
  • It’s a good negative indicator — if you can’t unit test the code, it’s of poor quality. Additionally, writing better code makes it easier to test

Software development is about maintainability. It is important to consider not only how long it takes for a programmer to develop a feature but, more importantly, how long it will take to maintain the application.

In other words, it can be understood as how easy it is to sustain the ongoing development of a piece of software. And development is not only about implementing new features or enhancements but also diagnosing and fixing issues that will be inevitably discovered along the way. Maintainable software is software that requires little effort to introduce new changes and where there is a low risk of introducing new defects upon change.

Software without tests

It can be worse. Bad tests are worse than no tests because we end up relying on something that is not correct. This situation can happen easily — we might write a test just to increase the test coverage or only check the happy path. While it might take longer for such a project to enter the stagnation phase, stagnation is still inevitable.

Software with bad tests

There are many types of tests. These tests can include unit tests, integration tests, end-to-end tests, and performance tests, and more. When beginning the testing, it is recommended to start with unit tests.

Why?

  • They are easy to set up
  • Verifies a single unit of behavior
  • Does it quickly
  • Does it in isolation from other tests

If you make some changes in the code, you need to verify fast if something is wrong or not. Even if the unit tests don’t test the app as a whole, you are able to detect most of the bugs. For example, you need to implement a new feature, which needs to change a method/function. You can easily forget that there is one edge case that is not obvious from the code because you are focused on the new feature. Without tests, there is a high probability you will overlook this case. And guess what? The new bug is here.

Wait, wait…

I can test my app manually. Yes, you can. In the beginning, it is very effective, but as the app grows, it slows you down, and there is a high probability of introducing new bugs. We are only humans, and we make mistakes…

You said that unit tests don’t test the app as a whole. So, do you think they can fix all the potential issues? Of course not, unit tests can’t address all potential issues. That’s why we have other tests for that — integration tests, end-to-end tests, etc.

If you are interested more in testing, you can continue here: TDD

Thank you for taking the time to read my article. I appreciate your interest in the topic and hope that it was informative. If you have any feedback or comments on the article, please don’t hesitate to share them with me.

--

--

Tomas Svojanovsky
Tomas Svojanovsky

Written by Tomas Svojanovsky

I'm a full-stack developer. Programming isn't just my job but also my hobby. I like developing seamless user experiences and working on server-side complexities

Responses (1)