为什么“ant junit”没有找到测试套件

当通过启用XML报告的ant -d运行junit-4.12测试用例时,我的测试套件不会执行。

这是build.xml的一部分:

<target name="compile" depends="prepare">
    <!-- kompilieren der Quelldateien -->
    <javac includeantruntime="false" srcdir="${source.dir}" destdir="${build.dir}">
        <classpath>
            <path refid="classPath"/>
                            <pathelement location="${lib.dir}/junit-4.12.jar" />
                            <pathelement location="${lib.dir}/hamcrest-all-1.3.jar" />
                            <pathelement location="test" />
                            <pathelement location="." />
        </classpath>
    </javac>
            <javac includeantruntime="false" srcdir="${tests.dir}" destdir="${build.dir}">
                    <classpath>
                            <path refid="classPath"/>
                            <pathelement location="${lib.dir}/junit-4.12.jar" />
                            <pathelement location="${lib.dir}/hamcrest-all-1.3.jar" />
                            <pathelement location="test" />
                            <pathelement location="." />
                    </classpath>
            </javac>

    <!-- kopieren der Dateien, die in den
        resources-Verzeichnissen liegen -->
    <copy todir="${build.dir}" overwrite="y">
        <fileset dir="${source.dir}">
            <!-- beruecksichtigt alle Verzeichnisse mit
                Namen resources und alle .properties Dateien -->
            <include name="**/resources/" />
            <include name="**/*.properties" />
        </fileset>
    </copy>
</target>
<target name="junit" depends="compile">
    <junit printsummary="yes" fork="false" haltonfailure="false"
    failureproperty="tests.failed" showoutput="true" dir="${build.dir}">
        <classpath>
            <path refid="classPath" />
            <pathelement location="${lib.dir}/junit-4.12.jar" />
            <pathelement location="${lib.dir}/hamcrest-all-1.3.jar" />
            <pathelement location="test" />
            <pathelement location="." />
            <!-- <path location="${source.dir}" /> -->
        </classpath>
        <formatter type="xml" />
        <batchtest todir="${report.dir}">
            <fileset dir="test">
                <exclude name="**/GMRTest*.class" />
                <include name="**/AllTests.class" />
            </fileset>
        </batchtest>
    </junit>
</target>

提前致谢!

格里特

PS这是我的JUnit Testsuite测试/ AllTests.java:

package test;

import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses;

import projekt.GMR;

@RunWith(Suite.class)
@SuiteClasses({ GMRTest.class,
            GMRTest2.class,
            GMRTest3.class})
public class AllTests {



  @BeforeClass 
  public static void setUpClass() {      
    System.out.println("Master setup");

  }

  @AfterClass public static void tearDownClass() { 
      System.out.println("Master tearDown");
  }

}

我必须在srcdir + package name = projekt dir编译,而不是srcdir = projekt dir

并在dir + package name = test dir进行dir + package name = test dir而不是dir = test dir

所以dirsrcdir等于. 在build.xml中

链接地址: http://www.djcxy.com/p/86093.html

上一篇: Why does "ant junit" not find the testsuite

下一篇: Running junit4 tests with ant 1.9.4 (jvm crash with fork=“true”)