CLion 2023.3 Help

Run, debug, terminate tests

Quick way

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 new tests.

    • The gutter icon marks successful tests.

    • The gutter icon marks failed tests.

    Running a test using the gutter icon

Customizable way

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

  2. Use the configuration switcher 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 Test Runner tab. For more information about analyzing test results, refer to Explore test results.

Stop tests

Use the following options on the Run toolbar of the Test Runner tab:

  • 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 Test Runner tab of 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 on the Run toolbar to rerun only failed tests.

    Hold Shift and click to choose whether you want to Run the 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 Test Runner 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: 23 February 2024