CLion 2017.3 Help

Running Tests

On this page:

Introduction

Generally, CLion runs and debugs tests in the same way as other applications, by running the run/debug configurations you have created. When doing so, it passes the specified test classes or methods to the test runner.

In many cases, you can initiate a testing session from a context menu. For this purpose, the Run and Debug commands are provided in certain context menus. For example, these commands are available for a test class, directory, or a package in the Project Tool Window. They are also available for a test class or method you are currently working on in the editor.

The tests run in the background, so you can execute several tests at the same time.

Each running configuration gets its own tab in the Run tool window (the Test Results tab). One tab can aggregate several tests.

Running or debugging a test

To run or debug a test, follow these general steps:

To start running or debugging a test, you can use the main toolbar, or a context menu in the Project tool window or in the editor:

  • Using the main toolbar:
    1. Select the necessary run/debug configuration from the list on the main toolbar.
    2. Click Run /help/img/idea/2017.3/run.png or Debug /help/img/idea/2017.3/debug.png to the right of the list. (Alternatively, choose Run | Run (Shift+F10) or Run | Debug (Shift+F9) from the main menu.)
  • Using a context menu:

    Right-click a test class in the Project tool window, or open it in the editor, and right-click the background. On the context menu, choose Run < class name> or Debug....

  • . Click /help/img/idea/2017.3/run@2x_gutter.png icon to run a single test, or /help/img/idea/2017.3/run_run@2x.png icon to run all tests from the suit (fixture, in case of Google Test):
    /help/img/idea/2017.3/cl_runTestGutter.png
    Note: following the first run of a test, the gutter icons indicate the test state: success (/help/img/idea/2017.3/icon_testsuccess@2x.png icon) or failed (/help/img/idea/2017.3/icon_testfailed2@2x.png icon), as in below example:
    /help/img/idea/2017.3/cl-failedTestGutter.png
Last modified: 24 October 2017

See Also

Reference: