|
109 | 109 | <fileset dir="test" includes="**/*.pac" />
|
110 | 110 | </copy>
|
111 | 111 |
|
112 |
| - <junit printsummary="yes" dir="${work.dir}" fork="true" showoutput="yes" failureproperty="test.failed"> |
| 112 | + <!-- XML and TXT reports will be written here --> |
| 113 | + <property name="test.reportdir" value="test-bin/results"/> |
| 114 | + <!-- Summary HTML report will be written here --> |
| 115 | + <property name="test.htmldir" value="test-bin/results/html"/> |
| 116 | + |
| 117 | + <!-- Remove the reportdir, so the HTML report only includes tests from this run --> |
| 118 | + <delete dir="${test.reportdir}" /> |
| 119 | + <mkdir dir="${test.reportdir}"/> |
| 120 | + <mkdir dir="${test.htmldir}"/> |
| 121 | + |
| 122 | + <!-- Sanity check: when single-test-methods is set, but single-test-class is not, raise an error --> |
| 123 | + <fail message="Need single-test-class if single-test-methods is set" if="single-test-methods" unless="single-test-class"/> |
| 124 | + |
| 125 | + <junit printsummary="yes" dir="${work.dir}" fork="true" showoutput="no" failureproperty="test.failed"> |
113 | 126 | <jvmarg value="-Djava.library.path=${java.additional.library.path}"/>
|
114 | 127 | <jvmarg value="-DWORK_DIR=."/>
|
115 | 128 | <jvmarg value="-ea"/>
|
|
121 | 134 | <path refid="class.path.test"/>
|
122 | 135 | </classpath>
|
123 | 136 |
|
| 137 | + <!-- Write XML files (for report-generation) and TXT files (for manual review) for every test class --> |
| 138 | + <formatter type="plain" /> |
124 | 139 | <formatter type="xml"/>
|
125 |
| - |
126 |
| - <batchtest fork="yes" todir="test-bin"> |
| 140 | + <!-- Print details to stdout when running a single test. Otherwise just a summary is printed for each test class (printsummary=yes above) --> |
| 141 | + <formatter type="plain" usefile="false" if="single-test-class"/> |
| 142 | + |
| 143 | + <!-- When both single-test-class and single-test-methods are specified, pass both to unit --> |
| 144 | + <test name="${single-test-class}" methods="${single-test-methods}" todir="${test.reportdir}" if="single-test-methods"/> |
| 145 | + <!-- When just single-test-class is specified, omit methods to run the entire class --> |
| 146 | + <test name="${single-test-class}" todir="${test.reportdir}" if="single-test-class" unless="single-test-methods"/> |
| 147 | + <!-- When neither are specified, run *all* testcases --> |
| 148 | + <batchtest fork="yes" todir="${test.reportdir}" unless="single-test-class"> |
127 | 149 | <fileset dir="test">
|
128 | 150 | <include name="**/*Test.java"/>
|
129 | 151 | <exclude name="**/Abstract*.java"/>
|
130 | 152 | </fileset>
|
131 | 153 | </batchtest>
|
132 | 154 | </junit>
|
133 | 155 |
|
| 156 | + <!-- Convert generated XML reports to browsable HTML --> |
| 157 | + <junitreport todir="${test.reportdir}"> |
| 158 | + <fileset dir="${test.reportdir}"> |
| 159 | + <include name="TEST-*.xml" /> |
| 160 | + </fileset> |
| 161 | + <report todir="${test.htmldir}" /> |
| 162 | + </junitreport> |
| 163 | + |
| 164 | + <!-- Make these paths relative to user.dir, which is the current directory when invoking ant (so the resulting paths are relative to the environment of the user. --> |
| 165 | + <property name="test.htmldir.display" location="${test.htmldir}" relative="true" basedir="${user.dir}"/> |
| 166 | + <property name="test.reportdir.display" location="${test.reportdir}" relative="true" basedir="${user.dir}"/> |
| 167 | + <echo message="Detailed test results can be found in ${test.reportdir.display}"/> |
| 168 | + <echo message="A browsable HTML summary is generated in ${test.htmldir.display}"/> |
| 169 | + |
134 | 170 | <fail if="test.failed"/>
|
135 | 171 | </target>
|
136 | 172 |
|
|
0 commit comments