Skip to main content

Code Coverage

[🚧 Under Construction]

Viewing Code Coverage in PhpStorm (in this case)​

To view code coverage in PhpStorm, you need to import a code coverage file. In many projects, these files are generated during the running of unit tests and stored in the Coverage directory.

Importing Coverage Files​

PhpStorm allows you to load lcov.info files via the Coverage Toolbar. Once a file is linked, you will automatically see the code coverage highlighted in your IDE.

To import a coverage file in PhpStorm:

  1. Go to the Coverage Toolbar.
  2. Click "Import a report collected in CI from disk".
  3. Select your lcov.info file.

PhpStorm supports lcov.info files well. If the import is successful, you should see a result similar to the screenshot provided in the original documentation.

Viewing Coverage in the IDE​

  • By default, the Project Toolbar will display the coverage.
  • When files are open, coverage is indicated next to the line numbers:
    • Green for covered lines
    • Red for uncovered lines

Notes on Coverage File Generation​

The method for generating coverage files and their storage location is project-specific. It is recommended to consult the README of the respective project for detailed instructions.

HTML Coverage Reports​

An lcov-report also generates HTML pages by default, allowing you to browse the coverage using a web browser. These reports can be found in the coverage folder at:

coverage/lcov-report/index.html