I must be missing something. The attached build.xml has a target "junit"
that causes the classes and test classes to be compiled to "build/..." and
then runs the tests. All the compiles work. The test get run. There are a
fair number of tests but after a few successes all the rest fail. All the
failure reports are due to ClassNotFound errors. When I then look in the
build folder all the compiled classes are gone. ... But there's no "delete"
command. It's driving me nuts. ... And the "compile" targets all work as
expected.

All the tests pass when run in IntelliJ IDEA, not via ANT.

I'm using ANT 1.7.
junit.jar (version 4.4) is in my lib folder -- so is on the classpath during
the build

Example test report:

Testsuite: my.stuff.SampleTest
Tests run: 1, Failures: 0, Errors: 1, Time elapsed: 0 sec

Caused an ERROR
my.stuff.SampleTest
java.lang.ClassNotFoundException: my.stuff.SampleTest
at java.lang.ClassLoader.loadClass(ClassLoader.java:250)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:398)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:247)


Any ideas?

TIA,
,chris
<?xml version="1.0" encoding="utf-8" ?>
<project name="Sandbox" default="compile" basedir=".">
    
    <description>
        Sandbox build file
    </description>
    
    <tstamp/>

    <path id="project.class.path">
        <pathelement path="${java.class.path}/"/>
        <fileset dir="lib">
            <include name="**/*.jar"/>
        </fileset>
    </path>

    <path id="project.test.path">
        <path refid="project.class.path"/>
        <pathelement path="build/classes"/>
        <pathelement path="build/test-classes"/>
    </path>
    
    <target name="init">
        <mkdir dir="build"/>
        <mkdir dir="build/classes"/>
        <mkdir dir="build/test-classes"/>
        <mkdir dir="build/test-reports"/>
    </target>

    <target name="compile" depends="init">
        <javac destdir="build/classes"
               includes="**" debug="on" debuglevel="lines,vars,source" source="1.5">
            <classpath refid="project.class.path"/>
            <src path="src"/>
        </javac>
    </target>

    <target name="compile.tests" depends="compile">
        <javac srcdir="test" destdir="build/test-classes"
               includes="**" debug="on" debuglevel="lines,vars,source" source="1.5">
            <classpath refid="project.test.path"/>
        </javac>
    </target>

    <target name="clean" description="Cleans the project of build artifacts">
        <mkdir dir="build"/>
        <delete includeemptydirs="yes">
            <fileset dir="build" includes="**" />
        </delete>
    </target>

    <target name="junit" depends="compile.tests" description="Run JUnit tests">

        <junit printsummary="yes">
            <classpath refid="project.test.path"/>
            <formatter type="plain"/>
            <batchtest todir="build/test-reports">
                <fileset dir="test">
                    <include name="**/*Test*.java"/>
                </fileset>
            </batchtest>
        </junit>
    </target>

</project>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to