Java Testing Framework
Java 8 이상
JUnit 5 구성

Project : Spring Boot
2.2+ 버전의 스프링 부트 프로젝트를 만든다면 기본으로 JUnit 5 의존성 추가된다.
스프링 부트 프로젝트를 사용하지 않는다면?
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.5.2</version>
<scope>test</scope>
</dependency>
import org.junit.jupiter.api.*;
import static org.junit.jupiter.api.Assertions.*;
class StudyTest {
@Test
void create() throws Exception {
//given
Study study = new Study();
//when
//then
assertNotNull(study);
System.out.println("create");
}
@Test
@Disabled
void createTwo() throws Exception {
System.out.println("create Two");
}
@BeforeAll
static void beforeAll() {
System.out.println("before all");
}
@AfterAll
static void afterAll() {
System.out.println("after all");
}
@BeforeEach
void beforeEach() {
System.out.println("before each");
}
@AfterEach
void afterEach() {
System.out.println("after each");
}
}
before all
before each
create
after each
StudyTest.createTwo() throws java.lang.Exception is @Disabled
after all