에러
JUnit 실행 시 initailizationError 발생
원인
1. ControllerTest에 @ContextConfiguration 선언을 안 한 경우.
2. classes 선언을 main 폴더 아래의 Application 이름으로 선언하지 않은 경우.
(test 폴더 아래 Application 에러로 선언한 경우 에러 발생)
해결
@ContextConfiguration(classes = ExampleApplication.class)
public class ExampleControllerTest {
// content
}
위와 같이 @ContextConfiguration 선언하여 해결해주었다.
후기
initailizationError 를 발생하는 경우 중 library를 추가 하지 않은 경우도 있는 것 같다.
참고하시길..
https://gabrielyj.tistory.com/211
[스프링/에러] initializationError에러 / Method 'initializationError' not found. Opening the test class.
스프링 프로젝트 JUnit 테스트에서 Method 'initializationError' not found. Opening the test class. 가 발생하는 원인은, 프로젝트에 JUnit 라이브러리가 추가되지 않았기 때문입니다. 아래의 과정을 거쳐 라..
gabrielyj.tistory.com
'JAVA > JUnit' 카테고리의 다른 글
[JUnit4][Error] Multipartfile 사용 시 tmp에 저장 안 되는 에러 (0) | 2022.02.20 |
---|---|
[JUnit4][Error] NullPointerException 에러 (0) | 2022.02.19 |