0
votes

I have two php projects: ProjectA and ProjectA-Test. ProjectA contains all the classes and methods for the applications, while ProjectA-Test contains the PHPUnit tests for those classes.

I am trying to set up code coverage reports in Jenkins to determine the coverage of these tests. The tests all run correctly, however, the code coverage report is for ProjectA-Test, rather than ProjectA.

I am using ant to trigger the PHPUnit tests:

<target name="phpunit" description="Run unit tests with PHPUnit">
   <exec executable="phpunit" failonerror="true" />
</target>

My phpunit.xml file looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<phpunit strict="true" verbose="true">
    <testsuites>
        <testsuite name="ProjectA-Test">
            <directory suffix='.php'>./src/</directory>
        </testsuite>
    </testsuites>

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

    <logging>
        <log type="coverage-html" target="build/coverage" title="Project A Test" charset="UTF-8" yui="true" highlight="true" lowUpperBound="35" highLowerBound="70"/>
        <log type="junit" target="build/logs/phpunit.xml" logIncompleteSkipped="false"/>
    </logging>

</phpunit>

The directory structure looks like this:

.
├── ProjectA
|   └── <PHP Files being tested>
└── ProjectA-Test
    ├── src
    |   └── <Unit test are all here>
    ├── build
    |   ├── logs
    |   |   └── phpunit.xml
    |   └── coverage
    |       └── <coverage reports are saved here>
    ├── phpunit.xml
    └── build.xml

Each test is annotated like this:

/**
 * @covers \ProjectA\ClassBeingTested::method_being_tested()
 */

How can I configure XDebug to set up the code coverage to assess the ProjectA classes, rather than ProjectA-Test files?

1

1 Answers

0
votes

Problem solved. I had a typo in the whitelist section of phpunit.xml