You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by ja...@apache.org on 2018/11/07 05:38:01 UTC
ant git commit: Update the junitlauncher task to explain the ability
to include JUnit libraries as part of the task's classpath
Repository: ant
Updated Branches:
refs/heads/master 59c792227 -> abce9225f
Update the junitlauncher task to explain the ability to include JUnit libraries as part of the task's classpath
Project: http://git-wip-us.apache.org/repos/asf/ant/repo
Commit: http://git-wip-us.apache.org/repos/asf/ant/commit/abce9225
Tree: http://git-wip-us.apache.org/repos/asf/ant/tree/abce9225
Diff: http://git-wip-us.apache.org/repos/asf/ant/diff/abce9225
Branch: refs/heads/master
Commit: abce9225f5f8d7091bbe0e50c8217eac65ad3424
Parents: 59c7922
Author: Jaikiran Pai <ja...@apache.org>
Authored: Wed Nov 7 11:06:56 2018 +0530
Committer: Jaikiran Pai <ja...@apache.org>
Committed: Wed Nov 7 11:06:56 2018 +0530
----------------------------------------------------------------------
manual/Tasks/junitlauncher.html | 74 +++++++++++++++++++++---------------
1 file changed, 43 insertions(+), 31 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ant/blob/abce9225/manual/Tasks/junitlauncher.html
----------------------------------------------------------------------
diff --git a/manual/Tasks/junitlauncher.html b/manual/Tasks/junitlauncher.html
index fb36259..1eb8b6b 100644
--- a/manual/Tasks/junitlauncher.html
+++ b/manual/Tasks/junitlauncher.html
@@ -102,15 +102,18 @@
To have these in the test classpath, you can follow <em>either</em> of the following approaches:
</p>
-<ul>
- <li>Put all these relevant jars along with the <samp>ant-junitlauncher.jar</samp>
+<ul id="setup">
+ <li id="setup-recommended"><b>Recommended approach since Ant 1.10.6</b>: Place the <samp>ant-junitlauncher.jar</samp> in <samp>ANT_HOME/lib</samp> directory
+ and use the nested <code><classpath></code> element to specify the location of the
+ the rest of the JUnit specific jars (noted above). Please read the
+ <a href=#nested-classpath>using classpath element</a> section for more details.</li>
+
+ <li>OR Put all these relevant jars along with the <samp>ant-junitlauncher.jar</samp>
in <samp>ANT_HOME/lib</samp> directory</li>
- <li>OR Leave <samp>ant-junitlauncher.jar</samp> in the <samp>ANT_HOME/lib</samp> directory and
+
+ <li>OR Put <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>
@@ -153,7 +156,7 @@
<h3 id="nested">Nested Elements</h3>
-<h4>classpath</h4>
+<h4 id="nested-classpath">classpath</h4>
<p>
The nested <code><classpath></code> element that represents
a <a href="../using.html#path">PATH like structure</a> can be used to configure the task to use
@@ -162,29 +165,16 @@
<ul>
<li>Finding the test classes to execute</li>
<li>Finding test engines that run the tests</li>
+ <li>If <a href="#setup-recommended">configured to do so</a>, finding all necessary JUnit libraries</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.
+ itself will be used for finding the test classes and the JUnit libraries.
</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.
+ Below is an example of setting up the classpath to include the Jupiter test engine and
+ the JUnit platform libraries during the execution of the tests.
<br/>
<pre>
<project>
@@ -197,6 +187,10 @@
<mkdir dir="${output.dir}"/>
</target>
+ <path id="junit.platform.libs.classpath">
+ <fileset dir="${basedir}/src/lib/junit-platform/"/>
+ </path>
+
<path id="junit.engine.jupiter.classpath">
<fileset dir="${basedir}/src/lib/jupiter/"/>
</path>
@@ -205,14 +199,23 @@
<mkdir dir="${build.classes.dir}"/>
<javac srcdir="${src.test.dir}"
destdir="${build.classes.dir}">
+ <!-- our tests only need JUnit Jupiter engine
+ libraries in our compile classpath for the tests -->
<classpath refid="junit.engine.jupiter.classpath"/>
</javac>
</target>
<target name="test" depends="compile-test">
<junitlauncher>
+ <!-- include the JUnit platform related libraries
+ required to run the tests -->
+ <classpath refid="junit.platform.libs.classpath"/>
+
+ <!-- include the JUnit Jupiter engine libraries -->
<classpath refid="junit.engine.jupiter.classpath"/>
+
<classpath>
+ <!-- the test classes themselves -->
<pathelement location="${build.classes.dir}"/>
</classpath>
<testclasses outputdir="${output.dir}">
@@ -226,13 +229,22 @@
</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
+ In the example above,
+ <ul>
+ <li>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>).</li>
+ <li>The <code>src/lib/junit-platform</code> directory is expected to
+ contain the JUnit platform jars (which have been
+ <a href="#junit-platform-libraries">listed in an earlier section of this
+ document</a>)</li>
+ </ul>
+ In the <code>test</code> target we use the <code>classpath</code> nested element
+ to point to the <code>junit.engine.jupiter.classpath</code> and <code>junit.platform.libs.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, all these classpaths can be combined
into one.
</p>