Perform unit testing with ease, as CLion integrates with Google Test, Catch, Boost.Test and Doctest frameworks.
There is a default way to run tests by simply running a regular executable in CLion. However to benefit from a built-in test runner, use special Google Test, Catch, Boost.Test, or Doctest configuration.
In case your CMake target is linked with gtest or gmock, this
configuration
will be created automatically. Or you can alternatively run a single test, fixture or
whole file by
pressing ⌃⇧R. In addition, you can create and update such configurations manually in
Run | Edit Configurations...
settings:
To narrow the set of tests in case of Catch configuration, use tags and benefit from the tag names completion:
Get the best of test-driven development with an easy-to-use and fluent unit test runner. Its dedicated view will show you:
Besides, CLion's test runner allows you:
Icons in the left gutter allow you to run/debug tests or run them with Valgrind Memcheck, as well as report the status of the tests: success or failure.
Code generation feature (Alt+Insert) can help a lot while writing unit tests. For Google Test create test, test fixture or SetUp/TearDown Methods.
In case of generating test for fixtures, TEST()
macro is
automatically converted
to the
appropriate TEST_F()
, TEST_P()
,
TYPED_TEST()
, or
TYPED_TEST_P()
:
CTest, a CMake-specific test runner, is supported in CLion. This means the list of tests that are run with CTest is detected, and the IDE automatically creates run/debug configurations for them. When tests are launched, the results are presented in the built-in test runner, from which you can debug tests, rerun only failed tests, and much more.