Quick Tip: FlexUnit & JUnitReport & haltonfailure

In case you are using flexunit ant task with your flex builds and you are used to failed builds with haltonfailure=”true”, you may notice that junitreport task is not executed when unit tests fails. Without having test reports, it does not give you much info about what went wrong. Fortunately, there is a solution using attribute failureproperty and fail ant task. Here is a quick ant build config to generate junitreport report for failed unit tests followed by build fail.

<flexunit toDir="${basedir}/${OUTPUT_DIRECTORY}"
    haltonfailure="false" verbose="true" localTrusted="true"

<mkdir dir="target/surefire-reports" />

<junitreport todir="target/surefire-reports">
    <fileset dir="${basedir}/${OUTPUT_DIRECTORY}">
        <include name="TEST-*.xml"/>
    <report format="frames" todir="target/surefire-reports/html"/>

<fail if="flexunit.failure" message="Unit test(s) failed. See reports!"/>

Notice: haltonfailure, failureproperty, fail

Where to go from here:

Leave a comment

Please be polite and on topic. Your e-mail will never be published.