GoLand 2019.2 Help

Running tests with code coverage

Basics

Code coverage results are displayed in tool windows and in the editor. The tool windows show the following information:

  • For a directory: the percentage of covered files and statements.

  • For a file: the percentage of the covered statements.

When a file is opened in the editor, each line is highlighted with regard to its code coverage status:

  • Lines executed during simulation are marked green.

  • Lines not executed during simulation are marked red.

The coverage measurement results comprise a coverage suite. You can have the results of a new simulation merged with any existing suite. In this case, a line will be considered covered if it is covered by at least one of the simulations.

A coverage suite is generated every time a test or application with code coverage measurement is executed. It is possible to have an unlimited amount of coverage suites.

Run with code coverage

General steps for using code coverage in a project

  1. Specify how you want to process the coverage results.

  2. Create a run/debug configuration for the target code, if you are going to measure code coverage for testing.

  3. Configure code coverage measurement in the desired run/debug configuration.

  4. Run with coverage, using the dedicated command from the main menu Run | Run with Coverage, or click the Run with Coverage button the Run with Coverage button.

  5. Once the run with coverage has been executed, you can perform the following actions:

Last modified: 21 August 2019

See Also