Question

I have created a build.xml file for phing to create code coverage reports. It uses

phpunit codecoverage="true"

and is pointed to the same file(s) as done with phpunit --coverage-html. The result differ, however. With phing I have 100% code coverage for all files, which I have not. There is probably something I don't know about running code coverage with phing that explains this 100%. What am I doing wrong to get differing results?

Was it helpful?

Solution

You can try running phpunit as an executable and --coverage-html as an argument (This is how we do it and seems to work well).

Example:

<target name="phpunit">
 <exec executable="phpunit" dir="${basedir}/source" failonerror="on">
  <arg line="--log-junit ${basedir}/build/logs/phpunit.xml
  --coverage-clover ${basedir}/build/logs/phpunit.coverage.xml
  --coverage-html ${basedir}/build/coverage
  tests/" />
 </exec>
</target>

OTHER TIPS

Example in first answer is not work. This example for Ant. The Phing ExecTask does not support the 'arg' as a nested element.

Working example for Phing:

<target name="phpunit">
    <exec command="phpunit --log-junit ${logsdir}/phpunit.xml 
        --coverage-clover ${logsdir}/phpunit.coverage.xml 
        --coverage-html ${logsdir}/coverage 
        tests/" />
</target>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top