2011-08-24 11 views
0

test 디렉토리에 각각 jUnit 테스트가 포함 된 패키지가 포함되어 있다고 가정합니다.ANT를 통해 jUnit 테스트 실행, 설명 필요

이 설정에서는 ANT를 사용하여 "모든 테스트를 실행 하시겠습니까??" , MyTests이

@RunWith(Suite.class) 
@Suite.SuiteClasses({ _ThisTest.class, _ThatTest.class }) 
public class OCTTests { 

} 

_ThisTest 자체가 몇 가지 테스트가 포함되어 있습니다 어디에 JUnit을 가정

이러한 문제가 발생하지 않도록하는 ANT 스크립트의 목적을 위해 가능한 그것을인가 ..

<target name="test" depends="compileTest"> 
    <junit fork="yes" printsummary="yes" haltonfailure="no"> 

     <classpath location="${bin}" /> 

     <formatter type="plain" /> 
     <test name="_com.??.project.alltests.MyTests" /> 

    </junit> 
</target> 

있다 단순히 "이 디렉토리에서 찾은 모든 테스트를 실행하십시오"라고 말하면됩니다.

답변

1

junit 작업의 nested batchtest 요소를 살펴보십시오. junit task 설명서 페이지에서 다음 예를 확인할 수 있습니다.

<junit printsummary="yes" haltonfailure="yes"> 
    <classpath> 
    <pathelement location="${build.tests}"/> 
    <pathelement path="${java.class.path}"/> 
    </classpath> 

    <formatter type="plain"/> 

    <test name="my.test.TestCase" haltonfailure="no" outfile="result"> 
    <formatter type="xml"/> 
    </test> 

    <batchtest fork="yes" todir="${reports.tests}"> 
    <fileset dir="${src.tests}"> 
     <include name="**/*Test*.java"/> 
     <exclude name="**/AllTests.java"/> 
    </fileset> 
    </batchtest> 
</junit>