Repository: ant Updated Branches: refs/heads/master 69a3f1c15 -> ddd729ba9
Update the junitlauncher manual to include an example of configuring a nested classpath for including test engines Project: http://git-wip-us.apache.org/repos/asf/ant/repo Commit: http://git-wip-us.apache.org/repos/asf/ant/commit/ddd729ba Tree: http://git-wip-us.apache.org/repos/asf/ant/tree/ddd729ba Diff: http://git-wip-us.apache.org/repos/asf/ant/diff/ddd729ba Branch: refs/heads/master Commit: ddd729ba977787ffb9397ad653b6ea88ffaf645e Parents: 69a3f1c Author: Jaikiran Pai <[email protected]> Authored: Sun Jun 3 15:07:07 2018 +0530 Committer: Jaikiran Pai <[email protected]> Committed: Sun Jun 3 15:07:07 2018 +0530 ---------------------------------------------------------------------- manual/Tasks/junitlauncher.html | 84 +++++++++++++++++++++++++++++++++--- 1 file changed, 78 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ant/blob/ddd729ba/manual/Tasks/junitlauncher.html ---------------------------------------------------------------------- diff --git a/manual/Tasks/junitlauncher.html b/manual/Tasks/junitlauncher.html index 5a132f3..8a32e42 100644 --- a/manual/Tasks/junitlauncher.html +++ b/manual/Tasks/junitlauncher.html @@ -52,7 +52,7 @@ are necessary to run the tests are: </p> -<ul> +<ul id="junit-platform-libraries"> <li> <samp>junit-platform-commons.jar</samp> </li> @@ -62,6 +62,9 @@ <li> <samp>junit-platform-launcher.jar</samp> </li> + <li> + <samp>opentest4j.jar</samp> + </li> </ul> <p> @@ -69,7 +72,7 @@ following libraries in the classpath </p> -<p> +<p id="junit-vintage-engine-libraries"> For <q>junit-vintage</q> engine: </p> @@ -82,7 +85,7 @@ </li> </ul> -<p> +<p id="junit-jupiter-engine-libraries"> For <q>junit-jupiter</q> engine: </p> @@ -93,9 +96,6 @@ <li> <samp>junit-jupiter-engine.jar</samp> </li> - <li> - <samp>opentest4j.jar</samp> - </li> </ul> <p> @@ -108,6 +108,9 @@ <li>OR Leave <samp>ant-junitlauncher.jar</samp> in the <samp>ANT_HOME/lib</samp> directory and include all other relevant jars in the classpath by passing them as a <kbd>-lib</kbd> option, while invoking Ant</li> + <li>OR Use the nested <code><classpath></code> element to specify the location of the + test engines. For more details about this approach, please read the + <a href=#test-engine-in-classpath>using classpath element to include test engines</a> section. </ul> <p> @@ -150,12 +153,81 @@ </p> <ul> <li>Finding the test classes to execute</li> + <li>Finding test engines that run the tests</li> </ul> <p> If the <code>classpath</code> element isn't configured for the task, then the classpath of Ant itself will be used for finding the test classes. </p> +<h5 id="test-engine-in-classpath">Using the classpath element to include test engines</h5> +<p> + The <code><classpath></code> can be used to include the test engines that you want to be + considered for execution of the tests. +</p> +<p> + <strong>NOTE:</strong> An important aspect to remember is that + whether or not you use this approach, the JUnit 5 platform libraries + <a href="#junit-platform-libraries">listed earlier in this + document</a> and the <code>ant-junitlauncher.jar</code>, <i>shouldn't</i> be part of this classpath + and instead they must be included in Ant runtime's classpath either by placing them + in <code>ANT_HOME/lib</code> or by passing the <code>-lib</code> option. +</p> +<p> + 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 + <code>ant-junitlauncher.jar</code> have been setup as explained previously. + <br/> + <pre> +<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> + </pre> + + In the example above, the <code>src/lib/jupiter</code> directory is expected to contain + the Jupiter test engine related jars (which have been + <a href="#junit-jupiter-engine-libraries">listed in an earlier section of this + document</a>). In the <code>test</code> target we use the <code>classpath</code> nested element + to point to the <code>junit.engine.jupiter.classpath</code> containing those jars. In this + <code>test</code> target we also use another <code>classpath</code> element to point to + the location containing our test classes. If required, both these classpath can be combined + into one. +</p> + <h4>listener</h4> <p>
