IntelliJ IDEA 2019.2 Help

Creating run/debug configurations for tests

To run tests in IntelliJ IDEA, you need to create a special run/debug configuration for the testing framework that you use.

Test run/debug configurations are synchronized with Xcodes schemes. All changes in them are propagated automatically.

Create run/debug configuration for tests

  1. Select Run | Edit Configuration from the main menu.

  2. In the Run/Debug Configurations dialog, click the Add New Configuration icon on the toolbar or press Alt+Insert. Select configuration for your testing framework: Boost.Test, Catch, Google Test, or XCTest.

    Add run/debug configuration for tests

  3. Depending on the testing frameworks, select the test type: Class/method or Patternfor XCTest, Suite/Test or Pattern for Google Test and Boost, or Tags/Test

  4. Specify the class/method, suit/test,

You can run your tests (test cases, test suites, and so on) You can run your tests using run/debug configurations, in the way similar to running ordinary applications.

To create the necessary run/debug configurations, you can use the general procedure (see Creating and Editing Run/Debug Configuration) or various shortcuts available in IntelliJ IDEA. Using these shortcuts (implemented as context menu commands) you can create the run/debug configurations for:

  • An individual test case.

  • All tests in a directory or a package.

  • Selected test classes which may be located in the same or different directories, packages or modules.

    This option is available only for JUnit.

  • An individual test method.

To create a run/debug configuration for tests, follow these general steps:

  1. To start creating the run/debug configuration, open the context menu for the item or items of interest and select the appropriate Create command. So, depending on what you want to create the run/debug configuration for, do one of the following:

    • If you want to create the run/debug configuration for an individual test or all tests in a directory or a package:

      1. Right-click the corresponding test class, directory or package in the Project Tool Window.

      2. Select the Create ... command from the context menu.

        The command name depends on your current selection in the Project tool window and may look something like:

        • Create "All Tests" for a source or test directory.

        • Create "Tests in '<package_name>'" for a package.

        • Create "<test_name>" for a test class.

    • If you want to create the run/debug configuration for selected tests:

      1. Select the tests of interest in the Project Tool Window.

      2. Right-click one of the selected tests to open the context menu.

      3. In the context menu, select Create "<first_test_name> and <n> more".

    • If you want to create the run/debug configuration for a test method:

      1. Open the test class containing the method of interest in the editor.

      2. To open the context menu, right-click somewhere within the method code.

      3. In the context menu, select Create "<method_name>()".

  2. In the dialog that opens, specify the run/debug configuration parameters and click OK. For more information, see the corresponding dialog description for JUnit or TestNG.

Last modified: 17 October 2019