CLion 2024.1 Help

Run, debug, terminate tests

Run tests directly in a file or folder

If your tests don't require any specific actions before start, and you don't want to configure additional options, such as code coverage, you can run them by using the following options:

  • Click the gutter icon next to the test or test suite/fixture.

    The gutter icon changes depending on the state of your test:

    • The gutter icon marks a set of tests.

    • The gutter icon marks new tests.

    • The gutter icon marks successful tests.

    • The gutter icon marks failed tests.

    Running a test using the gutter icon

Run tests using the Run widget

  1. Create a new test configuration or save a temporary one.

  2. Use the Run widget on the main toolbar to select the configuration you want to run.

  3. Click or press Shift+F10.

    Test configurations switcher

After CLion finishes running your tests, it shows the results in the Run tool window on the tab for that run configuration. For more information about analyzing test results, refer to Explore test results.

Stop tests

Use the following options on the Run toolbar of the tab for the run configuration:

  • Click the Stop button or press Ctrl+F2 to terminate the process immediately.

Rerun tests

Rerun a single test

  • Right-click a test on the tab for the run configuration in the Run tool window and select Run 'test name'.

    Rerunning a test

Rerun all tests in a session

  • Click the Rerun button on the Run toolbar or press Ctrl+F5 to rerun all tests in a session.

Rerun failed tests

  • Click the Rerun Failed Tests icon on the Run toolbar to rerun only failed tests.

    Hold Shift and click to choose whether you want to Run the failed tests again or Debug them.

    You can configure the IDE to trigger tests that were ignored or not started during the previous test run together with failed tests. Click the Settings button on the Run toolbar and enable the Include Non-Started Tests into Rerun Failed option.

Debug tests

  1. In the editor, click the gutter on the line where you want to set a breakpoint.

  2. Right-click the gutter icon next to the failed test and select Debug 'test name'.

    Debugging a failed test

    Alternatively, use the context menu of the test in the Test runner window:

    Test runner context menu

    The test will rerun in debug mode. After that, the test will be suspended, allowing you to examine its current state.

    You can step through the test to analyze its execution in detail.

Last modified: 03 August 2024