PhpStorm 2024.2 Help

Configure code coverage

Enable code coverage runner

In PhpStorm, you can use any of the following code coverage runners:

  • Xdebug, a debugging extension providing both the debugging and code coverage capabilities.

    To enable Xdebug, make sure at least the following settings are specified in the [xdebug] section of the active php.ini file.

    [xdebug] zend_extension="<path to xdebug extension>" xdebug.mode=coverage
    [xdebug] zend_extension="<path to xdebug extension>" xdebug.coverage_enable=1

    For more information, refer to Configure Xdebug.

  • PCOV, a lightweight extension only providing code coverage capabilities.

    To enable PCOV, download and install the extension as described in the PCOV documentation. Then, make sure at least the following settings are specified in the active php.ini file:

    extension="<path to pcov extension>"
  • phpdbg, a debugging and code coverage module, which is bundled in PHP 5.6 and later and requires no additional configuration.

    Configure code coverage behavior

    1. Press Ctrl+Alt+S to open settings and then select Build, Execution, Deployment | Coverage.

    2. Define how the collected coverage data will be processed:

      • Show options before applying coverage to the editor: show the Code Coverage dialog every time you run a new run configuration with code coverage.

      • Do not apply collected coverage: discard the new code coverage results.

      • Replace active suites with the new one: discard the active suites and use the new one every time you launch a new run configuration with code coverage.

      • Add to the active suites: add new code coverage suites to the active suites every time you launch a new run configuration with code coverage.

    3. Select the Activate Coverage View checkbox to open the Coverage tool window automatically.

    Change colors of the coverage highlighting

    1. Press Ctrl+Alt+S to open settings and then select Editor | Color Scheme | General.

    2. Alternatively, click the Edit Coverage Colors button in the popup that opens on clicking the coverage indication line in the gutter.

    3. In the list of components, expand the Line Coverage node and select a type of coverage: for example, Full, Partial or Uncovered.

    4. Click the Foreground field to open the Select Color dialog.

    5. Select a color, apply the changes, and close the dialog.

    Configure code coverage colors
    Last modified: 08 October 2024