I have a target named test and I want to do some tests.
I put here the important parts in build.xml. It includes:
When you run JUnit tasks, you must make sure both your classpath
that was used for your builds, and the path for the junit jars are added to your classpath.
I prefer to put the junit jars inside my project, so others don't have to install them in their machines for my build to work. I would install them in ${basedir}/antlib/junit
I use ${basedir}/antlib
to store all the various Ant build related jars such as the Ant-Contrib jars, JaCoCo, Findbugs, etc. Since this is inside my project, a checkout will always include these jars and the build will work for everyone:
This will create a path that contains your JUnit jars. Now to compile your junit tests:
Note that placing the JUnit jars in $ANT_HOME/lib
main not work because it depends whether
has includeAntRuntime
set or not. It's always highly recommended not to have this set in order to make your build more platform independent.
Also remember to include that junit.path
in your
task too.