0

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 Answer 1

0

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.