RubyMine 2017.2 Help

Code Coverage


Code coverage in RubyMine allows you to perform on-the-fly line coverage measuring for your code with low runtime overhead. In general, line coverage answers the question, "Was this line of code executed during unit testing simulation?"

Measuring code coverage is available for Test::Unit/Shoulda, Cucumber, RSpec, Rails, and Ruby Script.

Code coverage results are reflected in the dedicated Coverage tool window, in the Project view of the Project Tool Window, and in the editor. The tool windows show the following information:

  • For a directory: the percentage of the covered classes and lines.
  • For a file: the percentage of the covered lines.

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.


Code coverage is supported for Ruby 1.9 and is enabled by simplecov, which should be installed for your project.

Running with code coverage

To use code coverage in project, follow these general steps

  1. Make sure that the rcov or simplecov gem is installed, and Ruby is in your system path.

    If you are using Test::Unit/Shoulda, please refer to the section Test::Unit Special Notes. If a test is launched via a Rake task, it is the user's responsibility to provide code coverage measurement.

  2. Specify how you want to process the coverage results.
  3. Generate test or run the test generators for the target code, if you are going to measure code coverage for testing.
  4. Configure code coverage measurement in the desired run/debug configuration.
  5. Run with coverage, using the dedicated command on the main menu Run | Run with Coverage, or /help/img/idea/2017.2/runWithCoverage.png.
  6. Once the run with coverage has been executed, you can
Last modified: 26 October 2017

See Also