junit5의 기본 사용법을 이해할 수 있다.

계속해서 추가할 예정!

Maven Dependencies

<dependency>
    <groupId>org.junit.jupiter</groupId>
    <artifactId>junit-jupiter-engine</artifactId>
    <version>5.1.0</version>
    <scope>test</scope>
</dependency>
testRuntime("org.junit.jupiter:junit-jupiter-engine:5.1.0")

1. 기본 Annotation

@BeforeAll and @BeforeEach

@BeforeAll
static void setup() {
    log.info("@BeforeAll - executes once before all test methods in this class");
}
@BeforeEach
void init() {
    log.info("@BeforeEach - executes before each test method in this class");
}

@DisplayName and @Disabled

@DisplayName("Single test successful")
@Test
void testSingleSuccessTest() {
    log.info("Success");
}
@Test
@Disabled("Not implemented yet")
void testShowSomething() {
}

@AfterEach and @AfterAll

@AfterAll
static void done() {
    log.info("@AfterAll - executed after all test methods.");
}
@AfterEach
void tearDown() {
    log.info("@AfterEach - executed after each test method.");
}

2. Assertions and Assumptions

Assertions

Assumptions

3. Exception Testing

4. Test Suites

5. Dynamic Tests

6. ETC


관련된 Post

References