2016-11-16 14 views
0

ant -dを介してjunit-4.12テストケースをXMLレポートを有効にして実行すると、testsuiteは実行されません。「ant junit」がテストスイートを見つけられないのはなぜですか

これは、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テストスイートのテスト/ 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"); 
    } 

} 
+0

.両方等しいsrcdirこれはjunitReport Antターゲットの出力HTMLは:見つかりませんテスト: – Leder

+0

は '\t障害\t tests.AllTestsに junit.framework.AssertionFailedErrorが見つかりませテスト警告します java.lang.NoClassDefFoundErrorのは、Javaでjava.lang.ClassLoader.defineClass1で\t(ネイティブメソッド)\t:ALLTESTS(テスト/ ALLTESTS間違った名前):tests.AllTests' – Leder

+0

または 'ALLTESTS(テスト/ ALLTESTS間違った名前)で.lang.ClassLoader.defineClass(ClassLoader.java:763)\t(java.lang.ClassLoader.loadClass)(ClassLoader.java:357)\t(java.lang.Class.forName0)(ネイティブメソッド)\t(java.lang.Class.forName)(Class.java:348) ' – Leder

答えて

0

私はsrcdir + package name = projekt dir 代わりのsrcdir = projekt dirdir + package name = test dir 代わりのdir = test dir

とテストでコンパイルする必要がありました

S dir Oとのbuild.xml

関連する問題