Code Coverage Issue

Hi,

I can’t get code coverage to work ! I run following command :


codecept.bat run --coverage unit

All tests are ok (no error) and the following message is displayed :




Code Coverage Report

  2014-04-26 17:36:13


 Summary:

  Classes:  (0/0)

  Methods:  (0/0)

  Lines:	(0/0)



No error but no code coverage neither !

The codeception.yml file contains :




coverage:

	enable: true



… but no report is created. I tried to create a simple phpunit test case and run it with Phpunit (not codeception) and in this case, yes, the coverage report is generated successfully.

Any idea/hint/clue/advice I could use to fix this problem ?

Thanks in advance

B)

You need XDebug with coverage turned on.

Yes, I have XDebug turned on.

I made a test with only one unit test : SomeTest.php

When I run unit test using phpunit : [color="#008000"]coverage report is created[/color]




$ phpunit.bat --coverage-html ./_log/coverage  unit/SomeTest.php

PHPUnit 3.7.34 by Sebastian Bergmann.


Configuration read from F:\Project\ws1\yii2-basic\app\tests\phpunit.xml.dist

.

Time: 593 ms, Memory: 5.25Mb

OK (1 test, 1 assertion)

Generating code coverage report in HTML format ... done



When I run unit test using codeception : [color="#FF0000"]no coverage report is created[/color]




$ codecept.bat run --coverage unit

Codeception PHP Testing Framework v1.8.5

Powered by PHPUnit 3.7.34 by Sebastian Bergmann.


Unit Tests (1) ------------------------------

Running tests\unit\SomeTest::testMe 	Ok

---------------------------------------------


Time: 1.32 seconds, Memory: 8.25Mb


OK (1 test, 1 assertion)


Code Coverage Report

  2014-04-27 14:02:01


 Summary:

  Classes:  (0/0)

  Methods:  (0/0)

  Lines:	(0/0)



I don’t understand what I missed …

B)

I’ve solved this issue by running :


$my-project> ./vendor/bin/codecept.bat run unit ....

… instead of :


$my-project> codecept.bat run unit ...

In the latest case I was in fact using the global composer repository. It was on purpose but as it didn’t work, I’ve added the appropriate dependencies to my project and called codecept.bat from it.

Code coverage works fine now !

ciao

B)