Unit Testing for C++

Even if C++ is less “trendy” that current web development languages like JavaScript, it is still a fundamental technology for many embedded software development projects. In his article, Diego Dagum provides some basic principles of testing in C++.

The first step to test C++ is to pick a unit testing tool. The article propose many different open source C++ tools and the author pick up the Google Test C++ unit testing tool for his examples. The article then proposes some examples of C++ unit tests, mainly based on a Test-Driven Development (TDD). He discusses specifics aspects of unit testing like testing for exceptions, test templates and mocking.

His conclusion is that “Unit testing is one of the practices that make Agile processes viable. These processes encourage collective code ownership to avoid writing components used by just a few developers. This improves the ability to nimbly react to high-priority change needs, but this agility comes at the risk of accidentally introducing new bugs or breaking changes. A rich set of repeatable, automated unit tests will help you find these problems before Murphy does it for you.”

Read the complete article on https://visualstudiomagazine.com/articles/2013/03/08/unit-testing-with-c-plus-plus.aspx