Hi all,
at the moment it seems, that the ant task junit does not work. It tries
to run AllTests.java which is not a real junit test case in the sense,
that is has no public constructor and no test methods.
If I change the test class element in build.xml to a batchtest element
that includes all test classes and skips non test classes it sort of
works. There are a few tests that fail, but most of them work.
Should I commit those changes, or is there any other use case of the
junit target, that I am not aware of?
The real target I am aiming for is to have a target, that generates
reports for the junit test cases and extending it to give us test
coverage reports (as done in the attached diff).
Regards,
Felix
diff --git a/build.xml b/build.xml
index 09006d4..0d1b61d 100644
--- a/build.xml
+++ b/build.xml
@@ -2667,27 +2667,37 @@ run JMeter unless all the JMeter jars are added.
optional.jar is normally found in ANT_HOME/lib
-->
<target name="junit" depends="compile-tests"
- description="Run individual JUnit test (-Dtest.case=org.apache.jorphan.test.AllTests) (-Dtest.format=plain) (-Dtest.showoutput=true)">
+ description="Run individual JUnit test (-Dtest.case=org.apache.jorphan.test.AllTests) (-Dtest.format=plain) (-Dtest.showoutput=true)"
+ xmlns:jacoco="antlib:org.jacoco.ant">
<mkdir dir="reports"/>
<property name="test.format" value="plain"/>
<property name="test.case" value="org.apache.jorphan.test.AllTests"/>
<property name="test.showoutput" value="false"/>
+ <taskdef uri="antlib:org.jacoco.ant" resource="org/jacoco/ant/antlib.xml" />
+ <jacoco:coverage destfile="reports/jacoco.exec">
<junit fork="true"
- dir="${basedir}/bin"
- showoutput="${test.showoutput}"
- printsummary="on">
- <formatter type="${test.format}" usefile="yes"/>
- <formatter type="xml"/>
- <jvmarg value="-Dfile.encoding=${test.encoding}"/>
- <!-- Allow headless to be passed in -->
- <jvmarg value="-Djava.awt.headless=${java.awt.headless}"/>
- <classpath>
- <fileset dir="${dest.jar}" includes="*.jar"/>
- <pathelement location="${build.test}"/>
- <path refid="classpath"/>
- </classpath>
- <test name="${test.case}" todir="reports"/>
+ dir="${basedir}/bin"
+ showoutput="${test.showoutput}"
+ printsummary="on">
+ <formatter type="${test.format}" usefile="yes"/>
+ <formatter type="xml"/>
+ <jvmarg value="-Dfile.encoding=${test.encoding}"/>
+ <!-- Allow headless to be passed in -->
+ <jvmarg value="-Djava.awt.headless=${java.awt.headless}"/>
+ <classpath>
+ <fileset dir="${dest.jar}" includes="*.jar"/>
+ <pathelement location="${build.test}"/>
+ <pathelement location="${build.test-res}"/>
+ <path refid="classpath"/>
+ </classpath>
+ <batchtest todir="reports" skipNonTests="true">
+ <fileset dir="${src.test}">
+ <include name="**/*Test*.java" />
+ <exclude name="**/AllTests.java" />
+ </fileset>
+ </batchtest>
</junit>
+ </jacoco:coverage>
</target>
<!-- Utility target to collate reports -->