2012-06-12 3 views
4

각 테스트 스위트에는 많은 테스트 클래스가 포함되어 있습니다. 다음과 같이 나타납니다.테스트 스위트를 무시로 설정

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

@RunWith(Suite.class) 
@SuiteClasses({ATest.class, BTest.class}) 
public class MyFirstTestSuite { 

    @BeforeClass 
    public static void beforeClass() throws Exception { 
       // load resources 
    } 

    @AfterClass 
    public static void afterClass() throws Exception { 
     // release resources 

    } 
} 

경우에 따라 전체 테스트 스위트를 완전히 비활성화하고 싶습니다. 모든 테스트 스위트가 @BeforeClass@AfterClass을 사용하여 리소스를로드하고 릴리스하므로 각 테스트 클래스를 @Ignore으로 설정하지 않으므로 테스트 스위트가 무시 될 때이로드/릴리스를 건너 뛰고 싶습니다.

질문 : 전체 테스트 스위트에서 사용할 수있는 @Ignore과 비슷한 것이 있습니까?

답변

7

으로 TestSuite에 주석을 달 수 있습니다.

@RunWith(Suite.class) 
@SuiteClasses({Test1.class}) 
@Ignore 
public class MySuite { 
    public MySuite() { 
     System.out.println("Hello world"); 
    } 

    @BeforeClass 
    public static void hello() { 
     System.out.println("beforeClass"); 
    } 
} 

출력을 생성하지 않습니다.

+0

그것은했다. 감사! – adranale

0

SlowTest는 사용자가 정의한 클래스입니다. 함수 또는 속성없이 비워 둘 수 있습니다. 당신은 당신이 원하는대로 그 이름을 지정할 수 있습니다 :

enter image description here

enter image description here

관련 문제