I have a simple Junit test that keeps throwing a java.lang.ClassNotFoundException. Below is the folder structure
project:
|__build.xml
|__hamcrest-core-1.3.jar
|__junit.jar
|__src:
| |__Simple.java
|__bin:
|__Simple.class
Simple.java
import org.junit.Test;
public class Simple {
#Test
public void check() {
assert (true);
}
}
build.xml
<?xml version="1.0"?>
<project name="Ant-Test" default="main">
<target name="main">
<junit printsummary="yes" fork="yes" haltonfailure="no">
<classpath path="hamcrest-core-1.3.jar" />
<classpath path="junit.jar" />
<formatter type="plain" />
<batchtest fork="yes" todir="docs">
<fileset dir="bin">
<include name="**.class" />
</fileset>
</batchtest>
</junit>
</target>
</project>
Error:
Testsuite: Simple
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0 sec
Caused an ERROR
Simple
java.lang.ClassNotFoundException: Simple
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:582)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:185)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:496)
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Class.java:292)
Please help me find the reason for why this error occurs. The script is able to find the test case but at the end an error is thrown.
Add the required resources to the test classpath:
<pathelement path="${classpath}"/>
that in your case will be:
<classpath>
<pathelement path="bin" />
<pathelement location="hamcrest-core-1.3.jar" />
<pathelement location="junit.jar" />
</classpath>
As explained here
To make things a bit more flexible, we add one extra feature, which makes it possible to match multiple directory levels. This can be used to match a complete directory tree, or a file anywhere in the directory tree. To do this, "" must be used as the name of a directory. When ** is used as the name of a directory in the pattern, it matches zero or more directories. For example: /test/ matches all files/directories under /test/, such as /test/x.java, or /test/foo/bar/xyz.html, but not /xyz.xml.
'**' must be used to match folders, and not as wildcard to select partial file names.
Change your ant with:
<fileset dir="bin">
<include name="*.class" />
</fileset>
If you want to select all '*.class' files under every directory under bin/ then use:
<fileset dir="bin">
<include name="**/*.class" />
</fileset>
You will have now an error cause by the test report writer. You need to create a docs folder and everything will work.
The final build.xml will be:
<?xml version="1.0"?>
<project name="Ant-Test" default="main">
<target name="main">
<mkdir dir="docs"/>
<junit printsummary="yes" fork="yes" haltonfailure="no">
<classpath location="hamcrest-core-1.3.jar" />
<classpath location="junit-4.12.jar" />
<classpath path="bin/" />
<formatter type="plain" />
<batchtest fork="yes" todir="docs">
<fileset dir="bin">
<include name="**/*.class" />
</fileset>
</batchtest>
</junit>
</target>
</project>
Please try with following fileset tag:
<fileset dir="bin">
<include name="**.java" />
</fileset>
I'm not sure if junit task admits more than one classpath node, but anyway, it is a good practice to have just one. Moreover, your classpath is missing the classes directory. The right declaration would be like this:
<junit ...>
<classpath>
<pathelement path="bin"/>
<pathelement location="hamcrest-core-1.3.jar"/>
<pathelement location="junit.jar"/>
</classpath>
...
</junit>
Related
I'm using Jacoco code coverage in my Ant build and build is success after using instrument for my junit classes as they have powermockito in it.
I'm getting errors in the junit classes when i ran through the ant and tests failed but build success.
I'm comipiling the src and test classes using WAS server jars from another build.xml and placed the class files in the dir.build folder. This folder is given as input for the instrument task to give me the instrumented classes. When the junit task is started it is saying that errors occured in the test classes and test failed. I used the printsummary ="on" and tried to generate logs using verbose.
I want to know what are the errors occuring while running the junit. Can somebody please tell me how can i see the errors in the Test classes.
<?xml version="1.0" encoding="UTF-8"?>
<project name = "JunitIntegration" default = "report" xmlns:jacoco="antlib:org.jacoco.ant">
<taskdef uri="antlib:org.jacoco.ant" resource="org/jacoco/ant/antlib.xml">
<classpath path="./ant/lib/jacocoant.jar"/>
</taskdef>
<property name= "project.name" value = "Services"/>
<property name= "source.dir" value = "C:\\Thejesh\\Workspaces\\firstSetup\\Services"/>
<property name= "dir.build" value = "C:\\Thejesh\\Workspaces\\edpm_firstSetup\\build\\Services-classes"/>
<!-- Code coverage report -->
<property name= "result.dir" value = "C:\\Thejesh\\Workspaces\\edpm_firstSetup\\junitResults"/>
<property name= "result.classes.instr.dir" value = "${result.dir}/classes-instr"/>
<property name= "result.report.dir" value = "${result.dir}/site/jacoco"/>
<property name= "result.exec.file" value = "${result.dir}/jacoco.exec"/>
<import file="build-utils.xml"/>
<target name ="cleanL">
<delete dir ="${result.dir}"/>
</target>
<target name ="createL">
<mkdir dir ="${result.dir}"/>
<mkdir dir ="${result.classes.instr.dir}"/>
</target>
<target name ="instrument" depends = "cleanL, createL">
<jacoco:instrument destdir="${result.classes.instr.dir}">
<fileset dir="${dir.build}"/>
</jacoco:instrument>
</target>
<target name ="test" depends = "instrument">
<record name="${result.dir}/loggerinfo.log" loglevel="verbose" action="start"/>
<jacoco:coverage destfile="${result.exec.file}" xmlns:jacoco="antlib:org.jacoco.ant"
exclclassloader = "sun.reflect.DelegatingClassLoader">
<junit fork="true" forkmode="once" printsummary="on">
<formatter type= "xml"/>
<classpath>
<pathelement path="${dir.build}" />
<pathelement path="./ant/lib/jacocoagent.jar" />
<fileset dir ="C:\\Thejesh\\PIF\\Jars\\Common">
<include name ="*.jar*" />
</fileset>
</classpath>
<batchtest todir ="${result.dir}">
<fileset dir= "${result.classes.instr.dir}">
<include name ="**/*Test.class*"/>
</fileset>
</batchtest>
</junit>
</jacoco:coverage>
<record name="${result.dir}/loggerinfo.log" loglevel="verbose" action="stop"/>
</target>
<!-- Generating code coverage reports -->
<target name ="report" depends ="test">
<jacoco:report>
<executiondata>
<file file="${result.exec.file}"/>
</executiondata>
<structure name="JUnit intergration report">
<classfiles>
<fileset dir="${dir.build}"/>
</classfiles>
<sourcefiles encoding="UTF-8">
<fileset dir="${source.dir}"/>
</sourcefiles>
</structure>
<html destdir="${result.report.dir}"/>
<xml destfile ="${result.report.dir}/report.xml"/>
</jacoco:report>
</target>
<target name ="compiler" >
<junit.compile
projectdir="${source.dir}"
destfile="${dir.build}"
/>
</target>
</project>
One way that may help you. Hopefully someone can suggest an easier way - this is snippet from build.xml I used a few years ago before upgrade to JUNIT5.
<junit printsummary="on" showoutput="off" fork="true"
haltonerror="false" haltonfailure="false"
errorproperty="junit.errors" failureproperty="junit.failures" >
<formatter type="plain"/>
<formatter type="xml"/>
You'd need to check what outout files you get from JUNIT4 in your ${result.dir} and add ant action to grab and print out part of the junit output files to the console so that the final error lines were visible
<loadfile srcfile="${junit.stdout}" property="junit.summary">
<filterchain><tailfilter lines="30"/></filterchain>
</loadfile>
<echo>${junit.summary}</echo>
and then bail out of the build if there are errors:
<fail if="junit.failures">JUNIT failed - see ${result.dir}</fail>
<fail if="junit.errors" >JUNIT error - see ${result.dir}</fail>
When attempting to run tests with JUnit 5 via the Ant junitlauncher task, I receive the following message:
[junitlauncher] WARNING: TestEngine with ID 'junit-jupiter' failed to execute tests
[junitlauncher] java.lang.NoClassDefFoundError: org/hamcrest/SelfDescribing
How do I fix this so that my tests can run?
The answers to similar questions (e.g. this one) mainly say to make sure that hamcrest is on the classpath. I've verified using the print-test-classpath target (see build file below for details) that the classpath I'm using to run my tests includes hamcrest-2.1.jar. Furthermore, the tests compile without any issue.
Here are the sections of my build.xml I think are relevant:
<path id="lib-only-class.path">
<fileset dir="${lib.dir}">
<include name="**/*.jar" />
</fileset>
</path>
<path id="class.path">
<path refid="lib-only-class.path"/>
<pathelement location="${classes.dir}"/>
</path>
<path id="test-class.path">
<path refid="class.path"/>
<pathelement location="${test-classes.dir}"/>
</path>
<target name="compile-tests" depends="compile">
<mkdir dir="${test-classes.dir}"/>
<javac srcdir="${test.dir}" destdir="${test-classes.dir}"
includeantruntime="no" classpathref="class.path"/>
</target>
<target name="test" depends="compile-tests">
<junitlauncher printsummary="yes">
<classpath refid="test-class.path"/>
<testclasses>
<fileset dir="${test-classes.dir}"/>
</testclasses>
</junitlauncher>
</target>
<target name="print-test-classpath">
<pathconvert property="classpathInName" refid="test-class.path"/>
<echo>Classpath is ${classpathInName}</echo>
</target>
I'm trying to create an ant script to run pitest to be able to automate my mutation testing. I am getting the error:
Could not find or load main class org.pitest.mutationtest.commandline.MutationCoverageReport
This is my MutationTest.xml ant script
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project basedir="." default="mutationCoverage" name="PhoneBook">
<property name="ECLIPSE_HOME" value="C:/Program Files/eclipse/"/>
<path id="JUnit 4.libraryclasspath">
<pathelement location="${ECLIPSE_HOME}plugins/org.junit_4.11.0.v201303080030/junit.jar"/>
<pathelement location="${ECLIPSE_HOME}plugins/org.hamcrest.core_1.3.0.v201303031735.jar"/>
</path>
<path id="PhoneBook.classpath">
<pathelement location="bin"/>
<path refid="JUnit 4.libraryclasspath"/>
</path>
<path id="pit.path">
<pathelement location="lib/pitest-1.1.4.jar" />
<pathelement location="lib/pitest-ant-1.1.4.jar" />
</path>
<taskdef name="pitest" classname="org.pitest.ant.PitestTask" classpathref="pit.path" />
<target name="mutationCoverage">
<pitest
pitClasspath="PhoneBook.path"
classPath="PhoneBook.path"
targetClasses="pbook.*"
targetTests="pbook.*"
reportDir="MutationReports"
sourceDir="src"/>
</target>
</project>
What is causing this error, and how can I fix it?
Edit: I changed pitClasspath="PhoneBook.path" to pitClasspath="pit.path" and now I have a new error:
[pitest] Exception in thread "main" org.pitest.util.PitError: Unable to load class content for org.pitest.boot.HotSwapAgent
[pitest] Please copy and paste the information and the complete stacktrace below when reporting an issue
[pitest] VM : Java HotSpot(TM) 64-Bit Server VM
[pitest] Vendor : Oracle Corporation
[pitest] Version : 25.25-b02
[pitest] Uptime : 370
[pitest] Input ->
[pitest] BootClassPathSupported : true
[pitest] at org.pitest.mutationtest.tooling.JarCreatingJarFinder.classBytes(JarCreatingJarFinder.java:124)
[pitest] at org.pitest.mutationtest.tooling.JarCreatingJarFinder.addClass(JarCreatingJarFinder.java:113)
[pitest] at org.pitest.mutationtest.tooling.JarCreatingJarFinder.createJarFromClassPathResources(JarCreatingJarFinder.java:98)
[pitest] at org.pitest.mutationtest.tooling.JarCreatingJarFinder.createJar(JarCreatingJarFinder.java:74)
[pitest] at org.pitest.mutationtest.tooling.JarCreatingJarFinder.getJarLocation(JarCreatingJarFinder.java:63)
[pitest] at org.pitest.mutationtest.tooling.EntryPoint.execute(EntryPoint.java:70)
[pitest] at org.pitest.mutationtest.tooling.EntryPoint.execute(EntryPoint.java:43)
[pitest] at org.pitest.mutationtest.commandline.MutationCoverageReport.runReport(MutationCoverageReport.java:72)
[pitest] at org.pitest.mutationtest.commandline.MutationCoverageReport.main(MutationCoverageReport.java:43)
I don't know if that is better or worse, but hopefully it will be helpful in finding the problem.
A working example of a pitest ant build is provided at
https://github.com/hcoles/pitest-ant-example
I suggest you start with this and edit it until you have a working build for your codebase.
One difference I can see is that you have not included junit on the pitest path.
Your build looks a little strange as it seems to be tied to eclipse. If you are running from the IDE why not use the eclipse plugin?
Also, if you are not tied to Ant, you might want to consider maven as an alternative.
I believe much of your problem is that you're trying to use the Eclipse generated build.xml file, which doesn't contain the mutation testing target, and the target which you've added to remedy this has some errors.
I would suggest starting with the project here and attempting to understand how it works, and then changing their build.xml file to fit your needs.
However if this doesn't work, judging from your other question, the following build.xml should work if:
You divide your files into two source directories "src" and "test"
Both src and test folders contain the package "pbook"
You change the name of your tests to end in "Test" rather than begin in it
<?xml version="1.0" encoding="UTF-8"?>
<project name="Phonebook">
<property name="classOutputDir" value="build" />
<!-- classpath for pitest and any plugins -->
<path id="pitest.path">
<!-- must currently include the test library on the tool classpath. this will be fixed in a future version-->
<pathelement location="lib/junit-4.9.jar" />
<pathelement location="lib/pitest-0.33.jar" />
<pathelement location="lib/pitest-ant-0.33.jar" />
</path>
<taskdef name="pitest" classname="org.pitest.ant.PitestTask" classpathref="pitest.path" />
<target name="clean">
<delete dir="${classOutputDir}" />
</target>
<target name="compile" depends="clean">
<mkdir dir="${classOutputDir}/classes" />
<!-- Essential that line numbers and filenames are included in order for PIT to work -->
<javac srcdir="src" includeantruntime="false" debug="true" debuglevel="source,lines" destdir="${classOutputDir}/classes" />
</target>
<!-- classpath for compiling and testing the code. Note it does not include pitest and it's dependencies -->
<path id="test.path">
<pathelement location="${classOutputDir}/classes" />
<pathelement location="${classOutputDir}/test-classes" />
<pathelement location="lib/junit-4.9.jar" />
</path>
<target name="test" depends="compile">
<mkdir dir="${classOutputDir}/test-result" />
<mkdir dir="${classOutputDir}/test-classes" />
<javac includeantruntime="false" srcdir="test" destdir="${classOutputDir}/test-classes">
<classpath refid="test.path" />
</javac>
<junit>
<classpath refid="test.path" />
<batchtest todir="${classOutputDir}/test-result">
<!-- set test classes -->
<fileset dir="test">
<include name="**/*Test.java" />
</fileset>
<formatter type="xml" />
</batchtest>
</junit>
<junitreport todir="${classOutputDir}/test-result">
<fileset dir="${classOutputDir}/test-result">
<include name="TEST-*.xml" />
</fileset>
<report format="frames" todir="${classOutputDir}/test-result/report" />
</junitreport>
</target>
<!-- run pitest. note that the filters for tests and classes refer to package/class names, not source file named -->
<target name="pit" depends="test">
<path id="mutation.path">
<path refid="pitest.path"/>
<path refid="test.path"/>
</path>
<pitest pitClasspath="pitest.path" threads="2" classPath="mutation.path" targetTests="pbook.*" targetClasses="pbook.*" reportDir="pitReports" sourceDir="src" />
</target>
</project>
After doing so many trial and errors on "How ANT tag works ?", I decided to write my own custom build xml file for the testcases that was written in Java and integrated with JUnit. Unfortunately my build script failing with "ClassNotFoundException". And i can see the log in generated HTML file that you get to see after running ant build script.
Please see below
<project name="WebServices integrated with JUnit and generating report with ANT" default="test" basedir="." >
<description> REST Services integration with JUnit </description>
<!-- set global properties for this build -->
<property name="project_name" value="junit"/>
<property name="src" location="src"/>
<property name="build" location="bin"/>
<property name="dist" location="dist"/>
<property name="lib" location="${user.home}/My Documents/Mr/jars"/>
<property name="reports" location="reports"/>
<!-- the names of various distributable files. NOTE: Generating distribution file "target" is not used here-->
<!-- Delete the ${build} and ${dist} directory trees -->
<target name="clean" description="clean up">
<delete dir="${build}"/>
<delete dir="${dist}"/>
<delete dir="${reports}"/>
</target>
<!-- Top level targets -->
<target name="compile" depends="init" description="compile the source code">
<javac srcdir="${src}" destdir="${build}">
<classpath>
<fileset dir="${lib}">
<include name="**/*.jar"/>
</fileset>
</classpath>
</javac>
</target>
<!-- run your tests -->
<target name="run-tests" depends="compile" description="run your test suite">
<junit printsummary="yes" haltonfailure="no" showoutput="yes">
<classpath>
<pathelement path="${build}"/>
<fileset dir="${lib}">
<include name="**/*.jar"/>
</fileset>
</classpath>
<batchtest fork="yes" todir="${reports}/raw/">
<formatter type="xml"/>
<fileset dir="${src}/Test/Services" >
<exclude name="MyFile.java"/>
<include name="**/*.java"/> // <------ IMP***: Here I am saying include .java files that are based at "${src}/Test/Services".
</fileset>
</batchtest>
</junit>
</target>
<!-- generate report on tests -->
<target name="test" depends="run-tests">
<junitreport todir="${reports}">
<fileset dir="${reports}/raw/">
<include name="TEST-*.xml"/>
</fileset>
<report format="frames" todir="${reports}/html/"/>
</junitreport>
</target>
<target name="init" depends="clean" description="initialize the build envrionment">
<!--create the time stamp -->
<tstamp/>
<!-- Create directory structure -->
<mkdir dir="${build}"/> //<----dir for class files
<mkdir dir="${lib}"/> //<----dir for all my libraries
<mkdir dir="${dist}/lib"/> //<----not used
<mkdir dir="${reports}"/>
<mkdir dir="${reports}/raw/"/>
<mkdir dir="${reports}/html/"/> //<---- it will have output reports
</target>
<target name="all" depends="clean,test">
</target>
And I guessed ANT build will pick all the source files (.java) and then it will look for all the class files that are based in build folder and started running them, but then I see "classNotFoundException" in HTML report. please see below log :
CLASS : "getlieninfo"
> java.lang.ClassNotFoundException: getlieninfo
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:186)
After a while I changed .java to .class in "include" tag of my target called "run-tests" . The reason for doing this is, I thought ANT is not able to look ".java" files in source folder (src/Test/Services) hence I changed to ".class" and then modified dir attribute value in "fileset" tag to "build" so it may easily look for ".class" in BUILD folder where I will have compiled files stored. But none of my trial and error succeeded and ended up with same "classNotFoundException".
I am not sure what went wrong , can someone help me, please?
OK guys, Thanks for what ever little help I got from you. I found the problem.
I had to change include tag attribute name to "name=/Test/Services/**/*.java"/>" and modify dir attribute in fileset tag to "${src}" ; see below :
<batchtest fork="yes" todir="${reports}/raw/">
<formatter type="xml"/>
<fileset dir="${src}" >
<exclude name="MyFile.java"/>
<include name="/Test/Services/**/*.java"/> //<----this where i had to modify.
NOTE: Under src directory I have Test/Services folder which has source ".java" files in it.
</fileset>
</batchtest>
It solved my problem, but then i don't understand why ant build was not able to identify source files when i gave dir attribute as dir="${src}/Test/Services" that is in fileset tag
and kept name attribute in include tag as name="**/*.java" . My understanding is fileset tag should build the path for for the given dir path , once the path is build include tag will include or look for mentioned source files i.e. ".java" .
I'm trying to make an ant target that only runs the JUnit tests on a project without any other prior actions (no depends). I'm using Emma to instrument these in another target, and then I have another target that does a bytecode mutation on these instrumented classes. All that is working and I can get JUnit to run in that target after I've performed the instrumentation/mutation steps but I need to have the ability to just run the JUnit tests separately from this compile-instrument-mutate chain.
I've build a target that looks like this:
<target name="mutant-test-run" description="Run tests with mutation applied">
<path id="run.classpath">
<pathelement location="${out.dir}" />
</path>
<mkdir dir="${reports}" />
<junit printsummary="yes" fork="true">
<classpath>
<pathelement location="${out.instr.dir}" />
<path refid="junit.classpath" />
<path refid="famaLib.classpath" />
<path refid="run.classpath" />
<path refid="emma.lib" />
</classpath>
<jvmarg value="-Demma.coverage.out.file=${coverage.dir}/coverage.emma" />
<jvmarg value="-Demma.coverage.out.merge=true" />
<formatter type="plain" />
<formatter type="xml" />
<batchtest todir="${reports}">
<fileset dir="${src.dir}">
<include name="test1.java" />
<include name="test2.java" />
<include name="test3.java" />
<include name="test4.java" />
<include name="test5.java" />
</fileset>
</batchtest>
</junit>
<emma enabled="${emma.enabled}">
<report sourcepath="${src.dir}" sort="+block,+name,+method,+class" metrics="method:70,block:80,line:80,class:100">
<fileset dir="${coverage.dir}">
<include name="*.emma" />
</fileset>
<!-- for every type of report desired, configure a nested
element; various report parameters can be inherited from the parent <report>
and individually overridden for each report type:-->
<txt outfile="${coverage.dir}/coverage.txt" depth="package" columns="class,method,block,line,name" />
<xml outfile="${coverage.dir}/coverage.xml" depth="package" />
<html outfile="${coverage.dir}/coverage.html" depth="method" columns="name,class,method,block,line" />
</report>
</emma>
</target>
The jUnit task within the target doesn't get executed however, all I get is the output from the mkdir task and the emma task.
m1> ${ANT_HOME}/bin/ant -f nnbuild.xml -verbose mutant-test-run
Apache Ant(TM) version 1.8.2 compiled on July 5 2011
Buildfile: (Elided path here)/nnbuild.xml
Detected Java version: 1.6 in: /usr/lib64/jvm/java-1.6.0-sun-1.6.0/jre
Detected OS: Linux
parsing buildfile (Elided path)/nnbuild.xml with URI = file:(Elided path)/nnbuild.xml
Project base dir set to: (Elided path)
parsing buildfile jar:file:(Elided ANT_HOME path)/ant/lib/ant.jar!(Elided ANT_HOME path)/ant/antlib.xml with URI = jar:file:(Elided ANT_HOME path)/ant/lib/ant.jar!/org/apache/tools/ant/antlib.xml from a zip file
Build sequence for target(s) `mutant-test-run' is [mutant-test-run]
Complete build sequence is [mutant-test-run, emma, clean, init, compile, run, emma-run, merge, all, sofya, ]
mutant-test-run:
[mkdir] Skipping (Elided path)/reports because it already exists.
[emma] [EMMA v2.0, build 5312 (2005/06/12 19:32:43)]
[report] processing input files ...
[report] 1 file(s) read and merged in 48 ms
[report] nothing to do: no runtime coverage data found in any of the data files
BUILD SUCCESSFUL
Total time: 0 seconds
m1>
How do you setup an ant target to only do JUnit tests?
It looks like your fileset is wrong for the batchtest element, I think maybe you need to include a **:
<batchtest todir="${reports}">
<fileset dir="${src.dir}">
<include name="test1.java" />
<include name="test2.java" />
<include name="test3.java" />
<include name="test4.java" />
<include name="test5.java" />
</fileset>
</batchtest>
From the examples on the page JUnit Task, you can use:
<batchtest fork="yes" todir="${reports.tests}">
<fileset dir="${src.tests}">
<include name="**/*Test*.java"/>
<exclude name="**/AllTests.java"/>
</fileset>
</batchtest>
Where the ** means in any sub-directory.
Another example:
<batchtest todir="${collector.dir}" unless="hasFailingTests">
<fileset dir="${collector.dir}" includes="**/*.java" excludes="**/${collector.class}.*"/>
</batchtest>