티스토리 뷰

공부

[spring] assertThrows

승가비 2023. 9. 20. 00:22
728x90
import static org.junit.jupiter.api.Assertions.assertThrows;
 
@Test
public void junit5에서_exception_테스트_1() {
    Assertions.assertThrows(RuntimeException.class, () -> {
        DoSomething.func();
    });
}

https://covenant.tistory.com/256

 

완벽정리! Junit5로 예외 테스트하는 방법

환경 구성 testImplementation 'org.springframework.boot:spring-boot-starter-test' testRuntimeClasspath - Runtime classpath of source set 'test'. +--- org.springframework.boot:spring-boot-starter-web -> 2.5.6 \--- org.springframework.boot:spring-boot-sta

covenant.tistory.com

 

728x90
댓글