CLion 2017.3 Help

Boost.Test Support

Basics

Boost.Test is one of the most popular testing frameworks for C++ development. Boost.Test support in CLion includes:

  • Special Boost.Test Run/Debug configurations
  • Built-in test runner with the progress bar and a tree view of all the tests running
  • Ability to re-run failed tests, export test results, open previously saved results
  • Ability to navigate to the source code of a particular test
  • You can use CMake Live Templates to generate basic code constructs for Boost.Test.

Getting started with Boost.Test

To use the Boost.Test framework in your projects, do the following:

  1. Download Boost.Test.
  2. Add Boost.Test to your project. You can add headers to your project and point to the include directories. Another way is to link the Boost library with your targets in CMake, as follows:
    cl boostCMake
  3. Now you can run your tests
    cl runBoostTest
  4. See the tests results in Run Tool window:
    cl boostTestResult

Creating a Boost.Test Run/Debug configuration

Though you can simply run the Boost.Test target from your project as an ordinary configuration in CLion, to take advantage of the built-in test runner, create specific Boost.Test configuration (one or more). For every target it can be done automatically when you run a test/set of tests, or explicitly.

To create a Boost.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:
    cl boostTest Any
    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 suite 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:
    cl boostTest All

To create the Boost.Test run/debug configuration manually, do the following:

  • In the main menu, select Run | Edit Configurations. In the dialog that opens:
    1. Click add.png on the toolbar or press Alt+Insert. Select Boost.Test from the list.
    2. For the new Boost.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.
      • Specify common run/debug configuration parameters.
      • Apply the changes and close the dialog box.
      cl boostTest New

To update an existing configuration:
In the main menu, select Run | Edit Configurations. In the dialog that opens:

  • Expand the Boost.Test node and select the desired configuration.
  • Update the required fields and apply changes.
Last modified: 5 December 2017