Search code examples
command-linephpunitcode-coverage

PHPUnit: when run in command line, display code coverage?


I'm running tests PHPUnit from command line, but can't work out how to make it show the code coverage results in the terminal.

There are various command line options here in their documentation but they all involve outputting the results to a file in one of various formats.

Am I missing an obvious solution? Or would I need to write a batch file that executes:

  1. executes the PHPUnit command and flags that output code coverage to a file
  2. outputs the contents of the file to stdio so it appears in the terminal

Solution

  • File is not mandatory for --coverage-text option, you can run just

    ./phpunit.phar --coverage-text
    

    and get results in the terminal.