Why does "ant junit" not find the testsuite

When running junit-4.12 testcases via ant -d with XML reporting enabled my testsuite is not executed.

This is part of 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>

Thanks in advance!

Gerrit

PS This is my JUnit Testsuite test/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");
  }

}

I had to compile in srcdir + package name = projekt dir instead of srcdir = projekt dir

and test in dir + package name = test dir instead of dir = test dir

So dir and srcdir equal both to . in build.xml

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

上一篇: 对“非法同义词族”的解释

下一篇: 为什么“ant junit”没有找到测试套件