IntelliJ IDEA 2016.2 Help

Creating Run/Debug Configuration for Tests

Introduction

You can run your tests (test cases, test suites, etc.)
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.

You can run your tests even without creating the run/debug configurations for them. To do that,
use the Run (Ctrl+Shift+F10) or the Debug command
in corresponding context menus.

As a result, temporary run/debug configurations will be generated which you can then save.

Creating run/debug configuration for tests

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

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:

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

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

A similar context menu command is available for the whole test class in the editor.
To open the context menu for the class, right-click somewhere outside the area occupied by
the code of the methods (for example, in the line containing the class declaration).

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.

To distinguish between the context menu commands for JUnit and TestNG, the following icons are used: