특징
BeforeEach
AfterEach
예시
예제1
@BeforeEach
public void beforeEach() {
System.out.println("BeforeEach");
}
@AfterEach
public void afterEach() {
System.out.println("AfterEach");
}
차이점
BeforeAll, AfterAll
예제2
class StudyTest {
@Test
void create1() {
Study study = new Study();
assertNotNull(study);
System.out.println("create1");
}
@Test
void create2() {
System.out.println("create2");
}
@Test
@Disabled
void create3() {
System.out.println("create3");
}
@BeforeAll
static void beforeAll() {
System.out.println("beforeAll");
}
@AfterAll
static void afterAll() {
System.out.println("afterAll");
}
@BeforeEach
void beforeEach() {
System.out.println("beforeEach");
}
@AfterEach
void afterEach() {
System.out.println("afterEach");
}
}
beforeAll
beforeEach
create1
afterEach
beforeEach
create2
afterEach
afterAll
결론
