Unit testing is a best practice in any modern methodology, including Agile development. With automatic unit testing in place, if we introduce a bug into the software, one or more tests will fail and we’ll know about it immediately.
We’ve been writing in C++ for almost 30 years now, and we use software development tools, which improved over time. Yet, because of the intricacies of C++ and its different variants, testing tools did not become as advanced as Microsoft’s Visual Studio .NET tools, or Eclipse for Java. For example, the testing tooling for C++ in Visual Studio lags behind the tools for the other languages supported in Visual Studio.
Without good software testing and development tools, it is hard to write quality code, and become more productive. More bugs enter the code, which makes us go slower and may introduce instability into the system. Where the tools are weak, we need unit tests even more.
But tooling is just one part of the problem. We have code bases sometimes almost 30 year old, that were not written with tests. They mostly work, but what happens when we discover a bug there? Fixing the bug without tests in place may be riskier than fixing it! In addition, nobody in their right mind would change 30 year old legacy code that works, just to make it fit for testing. That would be just as risky.
Because of these problems, unit testing adoption in C++ is slower than in other languages. Which is paradoxical: Many mission-critical systems (automobile, medical devices, etc.) are written in C or C++. There is regulation in place for systems like this, for that reason. Yet we don’t do enough to ensure bugs don’t get in.
But all is not lost. There are tools for unit testing in C++. They maybe not as easy to use, but this is a small price to pay, in order to make sure the products are top quality. This may even save lives.
To learn more, download Isolator++ for Windows or Linux.