Reputation: 10822
I am using phing to build my CakePHP web application.
I want to have a phing target that goes along these lines:
For my test suite, I follow the CakePHP convention which uses PHPUnit
${cake} testsuite ${runinworkspaceapp} app AllTests --log-junit ${builddir}/logs/junit.xml
where
${cake}
simply means ${appdir}/Console/cake
${runinworkspaceapp}
means -app ${appdir}
I will generate a junit.xml file. Below is a snippet of the junit.xml
<testsuites>
<testsuite name="All Tests" tests="44" assertions="373" failures="0" errors="0" time="4.634020">
<testsuite name="All Model related class tests" tests="42" assertions="370" failures="0" errors="0" time="4.478717">
I suspect that I need to evaluate the junit.xml file in order to tell whether there is any error. I could be wrong and there is a better way.
How do I write the phing target?
Upvotes: 0
Views: 660
Reputation: 31117
Cake should exit with an exit code != 0
when at least one test failed, so using <exec>
with checkreturn="true"
should suffice.
junit.xml
can be converted to HTML with a phing task (also see http://cweiske.de/tagebuch/visualizing-phpunit-runs.htm):
<?xml version="1.0" encoding="utf-8"?>
<project name="testreport" default="gen-report" basedir=".">
<target name="gen-report">
<phpunitreport infile="log.junit.xml"
format="frames"
todir="html"
styledir="/usr/share/php/data/phing/etc/"
/>
</target>
</project>
Upvotes: 1