Unit-Testing Frameworks: Catch2
Let's learn about adopting a unit-testing framework called Catch2.
We'll cover the following...
It isn't extremely complicated to write a tiny unit-testing driver. It might not be pretty, but believe it or not, professional developers actually do like to reinvent the wheel (theirs will be fancier, rounder, and faster than the legacy one). Don't fall into this trap: we'll create so much boilerplate that it could become a separate project. Introducing a popular unit-test framework to our solution aligns it to a standard that transcends projects and companies and will get us free updates and extensions for cheap. We can't lose.
Unit-testing frameworks
How do we add a unit-testing framework to our project? Well, write tests in implementation files according to the chosen framework's rules and link these tests with a test runner provided by the framework. Test runners are our entry points that will start the execution of selected tests. Unlike the basic unit_tests.cpp
file we saw earlier, many of them will detect all the tests automatically. Beautiful.
We shall now introduce two unit-testing frameworks. We picked them for the following reasons: