Software Development 102: Testing

From Programmer to Software Engineer Part II

Nick Soetaert
4 min readFeb 11, 2023
Photo by Joshua Lawrence on Unsplash

In our previous article, “Software Development 101: From Programmer to Software Engineer,” we discussed the key skills and knowledge required to transition from being a programmer to a software engineer. In this follow-up article, we will dive deeper into the topic of software testing.

Why should I write tests? I hardly have enough time as-is.

Tests are an investment that will pay for themselves many times over by the time you finish a project. Here are some of the benefits that tests bring:

  1. Tests give you confidence to change things. Have you even been petrified to change an esoteric block of code? A well-tested piece of software can be changed by anyone, with confidence. If the change is bad, the tests will let you know. This gives developers confidence to make changes to the code, knowing that the tests will catch any unintended consequences of those changes.
  2. Tests are documentation. Tests serve as a form of documentation for the software, as they describe how the software should behave. This can be especially helpful for future developers who are working on the code.
  3. Debugging becomes faster and easier. Tests help to catch bugs and errors early in the development process before they become more difficult and time-consuming to fix. Furthermore, they can narrow down the search space of a bug from the whole program to specific functions.
  4. Improved collaboration. Tests help to ensure that different parts of the software work together as expected. This can be especially helpful in large development teams, as it helps to ensure that changes made by one developer do not break the work of another.
  5. Easier maintenance. As requirements change and the code evolves, tests help to ensure that the software continues to behave as expected.
  6. Tests improve software quality. In my experience, people who don’t write tests think that this is the only benefit of writing tests. Tests catch bugs and errors in the code, and verify that the software behaves as expected.

Software testing is a critical aspect of the software development process, as it helps to ensure that software is of high quality and meets user requirements. In Michael C. Feathers’ famed book Working Effectively with Legacy Code, the author describes legacy code as the following:

To me, legacy code is simply code without tests.

Types of tests

There are many types of tests, here are some of the most common:

  1. Unit Testing: Unit testing is a type of software testing that focuses on testing individual units of code, such as functions or methods, in isolation. It verifies that each unit of code behaves as expected, and helps to catch bugs and errors early in the development process. Unit tests are usually automated, and run frequently during development to ensure that changes to the code do not break existing functionality.
  2. Integration Testing: Integration testing is a type of software testing that focuses on testing the interactions between different parts of the software. It verifies that the components of the software work together as expected, and helps to identify issues that may not be apparent from unit testing. Integration testing is typically performed after unit testing, and can be automated or manual.
  3. System Testing: System testing is a type of software testing that focuses on testing the software as a whole, rather than individual units of code. It verifies that the software behaves as expected when used in a real-world scenario, and helps to identify issues with performance, compatibility, and overall functionality. System testing is typically performed after integration testing, and can be automated or manual.
  4. Acceptance Testing: Acceptance testing is a type of software testing that focuses on testing the software from a user’s perspective. It verifies that the software behaves as expected from the user’s point of view, and helps to ensure that the software meets user requirements. Acceptance testing is typically performed after system testing, and can be automated or manual. The goal of acceptance testing is to gain stakeholder approval for the software and ensure that it is ready for release.

You can think of these types of tests as a pyramid — with unit tests at the bottom (being the most numerous) and acceptance tests at the top (being the most scarce and expensive to run.)

Test Driven Development (TDD)

Now that you know what tests are and why they’re useful, here is one strategy to incorporate them into your development cycle.

Test Driven Development (TDD) is a software development process that emphasizes writing automated tests before writing the actual code. The process involves writing a test for a specific behavior or feature of the software, and then writing the minimum amount of code needed to make the test pass. This approach is then repeated for each behavior or feature of the software.

This is just one strategy to incorporate testing into your software development cycle that I find often works well.

--

--

Nick Soetaert

Software developer working with lots of IoT solar data. Follow me as I document problems I solve on the job.