gothinkster / slim-php-realworld-example-app

Exemplary real world application built with Slim
https://realworld.io
427 stars 96 forks source link

Not possible to generate code coveraget report with phpunit #3

Closed joostdecock closed 6 years ago

joostdecock commented 6 years ago

While the unit tests for this work out of the box, generating a code coverage report bails out with Undefined variable: app.

A code coverage report is very handy when writing tests. It would be great if this too would work out of the box.

alhoqbani commented 6 years ago

What command did you run to get Undefined variable: app?

joostdecock commented 6 years ago

I ran phpunit --coverage-text but it may have been a problem in my environment for it seems to be resolved now.

Sorry.

alhoqbani commented 6 years ago

Actually, I still get the same error when running composer test or phpunit --coverage-html I added processUncoveredFilesFromWhitelist=false to phpunit configuration file to resolve the issue. Running composer test now will generate coverage at public/tests/coverage/.

Thank you for bringing the issue to my attention.

panaceya commented 5 years ago

Affected for me when set directory to ./app

       <whitelist processUncoveredFilesFromWhitelist="true">
            <directory suffix=".php">./app</directory>
       </whitelist>

This is work:

       <blacklist>
            <directory suffix=".php">./vendor</directory>
        </blacklist>
        <whitelist processUncoveredFilesFromWhitelist="true">
            <directory suffix=".php">.</directory>
        </whitelist>