1
votes

I'm learning Zend Framework 2 after the ZF2 "Getting Started" tutorial. Now I have a simple application a PHPUnit test of the IndexController (the code is copied from the capitel "Unit Testing" of the tutorial). The testing works. Now I'm trying to create a code coverage report:

# phpunit --coverage-html ./report

or

# phpunit --coverage-html ./report ApplicationTest/Controller/IndexControllerTest.php

I expect a coverage report of the whole folder test (first example) or the IndexControllerTest (second example).

What I'm currently getting is this report:

enter image description here

Why? And how can I make the code coverage script process the files/folders, I want to analyze.

EDIT:

I can navigate to my module folder and see the report for it:

enter image description here

But the questions are remaining the same: (1) Why does it work so and (2) how can I make the code coverage script process (only) the files/folders, I want to analyze.

1

1 Answers

5
votes

You can include/exclude files or folders for code coverage using your phpunit.xml, see the phpunit manual.

Also you can ignore specific blocks of code from code coverage aggregation. See: http://www.phpunit.de/manual/3.2/en/code-coverage-analysis.html

PHPUnit code coverage is using xdebug to calculate the covered lines. If your IndexControllerTest also runs lines in order files they will show up in the coverage report as well.