개발자 '쑥말고인절미'
[Junit5] @DisplayName 본문
- 테스트 클래스와 테스트 메서드에 공백, 특수문자, 이모티콘를 사용하여 IDE에 표시되는 사용자 지정 표시 이름을 선언할 수 있음
- 공식 문서 예제
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
@DisplayName("A special test case")
class DisplayNameDemo {
@Test
@DisplayName("Custom test name containing spaces")
void testWithDisplayNameContainingSpaces() {
}
@Test
@DisplayName("╯°□°)╯")
void testWithDisplayNameContainingSpecialCharacters() {
}
@Test
@DisplayName("😱")
void testWithDisplayNameContainingEmoji() {
}
}
- 내 소스 및 실행화면
@DisplayName("비밀번호가 최소 8자 이상, 12자 이하면 예외가 발생하지 않는다.")
@Test
void validatePasswordTest() {
assertThatCode(() -> PasswordValidator.validate("serverwizard"))
.doesNotThrowAnyException();
}
참고링크
https://junit.org/junit5/docs/current/user-guide/#writing-tests-display-names
JUnit 5 User Guide
Although the JUnit Jupiter programming model and extension model do not support JUnit 4 features such as Rules and Runners natively, it is not expected that source code maintainers will need to update all of their existing tests, test extensions, and custo
junit.org
'STUDY > JUnit5 & AssertJ' 카테고리의 다른 글
[JUnit5 & AssertJ] JUnit5, AssertJ 소개 (0) | 2024.05.17 |
---|