Search code examples
phpcode-coveragephpunitphing

phing versus phpunit codecoverage results


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?


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>