Java Ant和JUnit:未执行测试

Java Ant和JUnit:未执行测试,java,ant,junit,Java,Ant,Junit,使用Ant,您需要运行JUnit测试。要使用此代码,请执行以下操作: <target name="tempTest"> <mkdir dir="<folder in which to create the class-file>" /> <javac destdir="<folder in which to create the class-file>" srcdir="<f

使用Ant,您需要运行JUnit测试。要使用此代码,请执行以下操作:

<target name="tempTest">
        <mkdir dir="<folder in which to create the class-file>" />
        <javac destdir="<folder in which to create the class-file>"
               srcdir="<folder in which the java-file with junit-test>"
               debug="on"
               memorymaximumsize="128m"
               fork="true"
               encoding="utf-8">
            <classpath>
                <fileset dir="<folder, which is located in junit.jar>" includes="junit.jar"/>
            </classpath>
        </javac>
        <junit printsummary="on" haltonfailure="no">
            <classpath>
                <fileset dir="<folder, which is located in junit.jar>" includes="junit.jar"/>
                <pathelement location="<folder in which to create the class-file (in this step, class-file has been created in this folder)>"/>
            </classpath>
            <formatter type="plain"/>
            <batchtest todir="<folder in which the file will be created for output to a test error>">
                <fileset dir="<folder in which the java-file with junit-test>"/>
            </batchtest>
        </junit>
</target>
但是,运行ant脚本文件时,会显示错误:

Testsuite: TempTest
Tests run: 1, Failures: 0, Errors: 1, Time elapsed: 0 sec

    Caused an ERROR
TempTest
java.lang.ClassNotFoundException: TempTest
    at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:270)
    at com.intellij.rt.ant.execution.AntMain2.main(AntMain2.java:30)
请告诉我,如何解决这个问题

UPD:

这个问题已经解决了

为了运行junit,测试行必须

<batchtest todir="<folder in which the file will be created for output to a test error>">
    <fileset dir="<folder in which the java-file with junit-test>"/>
</batchtest>
取代

<batchtest todir="<folder in which the file will be created for output to a test error>">
    <fileset dir="<folder in which to create the class-file (in this step, class-file has been created in this folder)>"/>
</batchtest>
<batchtest todir="<folder in which the file will be created for output to a test error>">
    <fileset dir="<folder in which to create the class-file (in this step, class-file has been created in this folder)>"/>
</batchtest>