From ddd729ba977787ffb9397ad653b6ea88ffaf645e Mon Sep 17 00:00:00 2001
From: Jaikiran Pai
@@ -69,7 +72,7 @@ following libraries in the classpath
-+
For junit-vintage
engine:
+
For junit-jupiter
engine:
@@ -108,6 +108,9 @@
<classpath> element to specify the location of the
+ test engines. For more details about this approach, please read the
+ using classpath element to include test engines section.
@@ -150,12 +153,81 @@
If the classpath element isn't configured for the task, then the classpath of Ant
itself will be used for finding the test classes.
+ The <classpath> can be used to include the test engines that you want to be
+ considered for execution of the tests.
+
+ NOTE: An important aspect to remember is that
+ whether or not you use this approach, the JUnit 5 platform libraries
+ listed earlier in this
+ document and the ant-junitlauncher.jar, shouldn't be part of this classpath
+ and instead they must be included in Ant runtime's classpath either by placing them
+ in ANT_HOME/lib or by passing the -lib option.
+
+ Below is an example of setting up the classpath to include the Jupiter test engine during the
+ execution of the tests. We assume that the JUnit 5 platform libraries and the
+ ant-junitlauncher.jar have been setup as explained previously.
+
+
+<project>
+
+ <property name="output.dir" value="${basedir}/build"/>
+ <property name="src.test.dir" value="${basedir}/src/test"/>
+ <property name="build.classes.dir" value="${output.dir}/classes"/>
+
+ <target name="init">
+ <mkdir dir="${output.dir}"/>
+ </target>
+
+ <path id="junit.engine.jupiter.classpath">
+ <fileset dir="${basedir}/src/lib/jupiter/"/>
+ </path>
+
+ <target name="compile-test" depends="init">
+ <mkdir dir="${build.classes.dir}"/>
+ <javac srcdir="${src.test.dir}"
+ destdir="${build.classes.dir}">
+ <classpath refid="junit.engine.jupiter.classpath"/>
+ </javac>
+ </target>
+
+ <target name="test" depends="compile-test">
+ <junitlauncher>
+ <classpath refid="junit.engine.jupiter.classpath"/>
+ <classpath>
+ <pathelement location="${build.classes.dir}"/>
+ </classpath>
+ <testclasses outputdir="${output.dir}">
+ <fileset dir="${build.classes.dir}"/>
+ <listener type="legacy-brief" sendSysOut="true"/>
+ <listener type="legacy-xml" sendSysErr="true" sendSysOut="true"/>
+
+ </testclasses>
+ </junitlauncher>
+ </target>
+</project>
+
+
+ In the example above, the src/lib/jupiter directory is expected to contain
+ the Jupiter test engine related jars (which have been
+ listed in an earlier section of this
+ document). In the test target we use the classpath nested element
+ to point to the junit.engine.jupiter.classpath containing those jars. In this
+ test target we also use another classpath element to point to
+ the location containing our test classes. If required, both these classpath can be combined
+ into one.
+
+