Skip to content
This repository
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

file 58 lines (53 sloc) 1.988 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
<?xml version="1.0" ?>

<project name="test" basedir=".">
  <macrodef name="run_junit_tests" description="Macro for running junit tests">
    <attribute name="testclasspath"/>
    <attribute name="testfileset"/>
    <attribute name="outputdir"/>
    <attribute name="failbuild" default="true"/>

    <sequential>
      <condition property="isUnix">
        <os family="unix"/>
      </condition>
      <echo message="@{outputdir}"/>
      <mkdir dir="@{outputdir}"/>
      <junit forkMode="perBatch"
             printsummary="yes"
             haltonfailure="false"
             failureproperty="junit.test.failure"
             haltonerror="false"
             errorproperty="junit.test.error"
             showoutput="true"
             dir=".">
        <jvmarg value="-Dfile.encoding=ISO-8859-1"/>
        <classpath refid="@{testclasspath}"/>
        <formatter type="xml"/>
        <batchtest fork="yes" todir="@{outputdir}">
          <fileset refid="@{testfileset}"/>
        </batchtest>
      </junit>
      <condition property="tests.failed.or.errored">
        <and>
          <or>
            <isset property="junit.test.failure"/>
            <isset property="junit.test.error"/>
          </or>
          <istrue value="@{failbuild}"/>
        </and>
      </condition>
      <antcall target="-generate_junit_report_and_fail">
        <param name="_junit_report_dir_" value="@{outputdir}"/>
      </antcall>
    </sequential>
  </macrodef>

  <target name="-generate_junit_report_and_fail"
          description="Generate the unit test report if tests failed and cause build to stop short">
    <echo message="Outputting to ${_junit_report_dir_}/output"/>
    <junitreport todir="${_junit_report_dir_}">
      <fileset dir="${_junit_report_dir_}">
        <include name="TEST-*.xml"/>
      </fileset>

      <report format="frames" todir="${_junit_report_dir_}/output"/>
    </junitreport>
  </target>

</project>
Something went wrong with that request. Please try again.