카테고리 없음
[JUnit5] 기본 테스트 어노테이션 @Test, @BeforeAll, @BeforeEach, @AfterAll, @AfterEach, @Disabled
비타민찌
2022. 9. 16. 02:01
728x90
@Test
이 어노테이션을 붙이면 Test 메서드로 인식하고 테스트 한다.
@Test
void test1() {
Study study = new Study();
System.out.println("test1");
}
@BeforeAll
본 어노테이션을 붙인 메서드는 해당 테스트 클래스를 초기화할 때 딱 한번 수행되는 메서드다.
메서드 시그니쳐는 static 으로 선언해야한다.
@BeforeAll
static void beforeAll() {
System.out.println("BeforeAll");
}
@BeforeEach
본 어노테이션을 붙인 메서드는 테스트 메서드 실행 이전에 수행된다.
@BeforeEach
void beforeEach() {
System.out.println("BeforeEach");
}
@AfterAll
본 어노테이션을 붙인 메서드는 해당 테스트 클래스 내 테스트 메서드를 모두 실행시킨 후 딱 한번 수행되는 메서드다.
메서드 시그니쳐는 static 으로 선언해야한다.
@AfterAll
static void afterAll() {
System.out.println("AfterAll");
}
@AfterEach
본 어노테이션을 붙인 메서드는 테스트 메서드 실행 이후에 수행된다.
@AfterEach
void afterEach() {
System.out.println("AfterEach");
}
@Disabled
본 어노테이션을 붙인 테스트 메서드는 무시된다.
@Disabled
@Test
void disabledTest() {
System.out.println("Disabled");
}
728x90