Running Google Test tests
After setting up Google Test with your CMake project and compiling your tests, running them is straightforward. You execute the tests using the ctest
command in your build directory, which CMake uses to run tests defined in your CMakeLists.txt
file.
When you run the tests for a Calculator
class, the standard output to your terminal might look like this if you execute the test binary directly:
$ cd path/to/build [==========] Running 4 tests from 2 test suites. [----------] Global test environment set-up. [----------] 2 tests from AdditionTests [ RUN ] AdditionTests.HandlesZeroInput [ OK ] AdditionTests.HandlesZeroInput (0 ms) [ RUN ] AdditionTests.HandlesPositiveInput [ OK ] AdditionTests.HandlesPositiveInput (0 ms) [----------] 2 tests from AdditionTests (0 ms total) [----------] 2 tests from SubtractionTests...