mercredi 31 août 2016

PHPUnit - End to End testing with code coverage

I am actually trying to track my code coverage with PhpUnit.

After following the basic instruction from documentation and few tutorials, I make it work...

Sadly my tests (49 tests, 100% passing) for all CRUD features of my webservice's models, gives me an average of ... 0% coverage.

My test policy is End to End : A test execute a curl request to the WebService and expect an HTTP response (assert on HTTP Code value, response content and so on).

Both tests and webserver are hosted localy.

This is my phpunit.xml

    <?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://ift.tt/ra1lAU"
         xsi:noNamespaceSchemaLocation="http://ift.tt/2bJbO5J"
         bootstrap="config.php"
         backupGlobals="false"
         beStrictAboutCoversAnnotation="true"
         beStrictAboutOutputDuringTests="true"
         beStrictAboutTestsThatDoNotTestAnything="true"
         beStrictAboutTodoAnnotatedTests="true"
         verbose="true">
    <testsuites>
        <testsuite name="Users">
            <directory>
                ./tests/1-UsersSuite
            </directory>
        </testsuite>
        <testsuite name="Catalogs">
            <directory>
                ./tests/2-CatalogsSuite
            </directory>
        </testsuite>
        <testsuite name="Subscriptions">
            <directory>
                ./tests/3-SubscriptionsSuite
            </directory>
        </testsuite>
    </testsuites>

    <filter>
        <whitelist processUncoveredFilesFromWhitelist="true">
            <directory suffix=".php">controllers</directory>
            <directory suffix=".php">models</directory>
        </whitelist>

        <blacklist>

        </blacklist>
    </filter>
</phpunit>

enter image description here

enter image description here

I successfully built a similar test environment with node and Istanbul (Istanbul was running the Server to generate the code coverage report)

With my php stack it's quite different, request are passing from nginx -> php-fpm compiled with xdebug (I am able to use step-by-step debug feature)

PhpUnit is probably designed for Unit testing... it's probably why I am struggling with my End to End tests.

Thx for your help, best regards.

Aucun commentaire:

Enregistrer un commentaire