Google Test Support
Creating a Google Test run/debug configuration
Though you can simply run the Google Test target from your project as an ordinary configuration in CLion, to take advantage of the built-in test runner, create specific Google Test configuration (one or more). You can do it automatically, when you run a test/set of tests, or explicitly.To create a Google Test run/debug configuration automatically, do one of the following:
- In the editor, place caret on any line of a test code and run the test from the context menu or by pressing Ctrl+Shift+F10. CLion creates the related run/debug configuration automatically, as in example: You can rerun it later, when needed.
- In the project view, select a test source file (you can also place the caret in that file code in the editor or on a fixture name). In the context menu, select Run All in ... or press Ctrl+Shift+F10 to run the test. CLion automatically creates and saves the following configuration, which you can reuse later:
In the main menu, select . In the dialog that opens:
the toolbar or press Alt+Insert. Select Google Test from the list.
For the new Google Test run/debug configuration:
- Specify its name in the Name text box. This name will be shown in the list of the available run/debug configurations.
- Select the Suite/Test radio button to run a particular or all the tests of a suite. Select Pattern radio button to run all the tests of a particular pattern.
- Specify the suite name in the suite text box. Note, that this option is available only when the Suite/Test radio button is selected.
- Select the desired test from the Test drop down list. Note, that this option is available only when the Suite/Test radio button is selected.
- Specify the pattern name in the Pattern text box. Note, that this option is available only when the Pattern radio button is selected.
- In the Target field, select the desired target from the list of available targets.
- In the Configuration field, select the desired configuration type from the list of available types. You can use configuration types other than provisioned by IDE. Refer to Changing Configuration Page page for details.
- Specify common run/debug configuration parameters.
- Apply the changes and close the dialog box.
- Click on the toolbar or press Alt+Insert. Select Google Test from the list.
- Expand the Google Test node and select the desired configuration.
- Update the required fields and apply changes.