JUnit ant task – JUnit task not found
•
Java
I'm trying to build from my ant Run JUnit test from the. XML file I read here, you can use JUnit Jar file instead of using the In the home / lib directory jar. This is what I want to do, because our Jenkins Autobuild is set in his ant lib directory without JUnit Jar file
Even with the simplest projects, I always get errors that junittask can't find If you look at my build XML file, which is obviously included in the JUnit task and used for it
build. xml:
<project default="all"> <property name="TALK" value="false" /> <path id="classpath.base"> </path> <path id="classpath.test"> <fileset dir="." includes="**/*.jar" /> </path> <target name="compile-test"> <javac srcdir="src" verbose="${TALK}"> <classpath refid="classpath.test" /> </javac> </target> <target name="test" depends="compile-test"> <junit> <classpath refid="classpath.test" /> <formatter type="brief" usefile="false" /> <test name="TestClass" /> </junit> </target> <target name="all" depends="test" /> </project>
The small example I used to test looks like this:
Edit: update based on answers
Solution
JUnit documentation is a bit sparse
<path id="classpath.test"> <fileset dir="." includes="*junit.jar" /> </path> <taskdef name="junit" classname="org.apache.tools.ant.taskdefs.optional.junit.JUnitTask"> <classpath refid="classpath.test"/> </taskdef>
This can be used to check the path:
<pathconvert property="testoutput" refid="classpath.test"/> <echo>Path = ${testoutput}</echo>
Document: JUnit task
Additional information can be found in this chat transcript
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码