Defining, discovering, and running tests
Testing is the staple diet for any software engineer who takes pride in quality software. The number of frameworks for writing unit tests in the various languages is huge and, especially for C++, CMake includes modules to work with most of the more popular ones.
At very abstract levels, all unit testing frameworks do the following:
- Allow the formulating and grouping of test cases.
- Contain some form of assertion to check for various test conditions.
- Discover and run the test cases, either altogether or a selection of them.
- Produce the test result in a variety of formats, such as plain text, JSON, XML, and possibly more.
With the CTest utility, CMake includes a built-in way to execute almost any test. Any CMake project that has set enable_testing()
and added at least one test with add_test()
has testing support enabled. Any call to enable_testing()
will enable test discovery in the current directory and any directory...