Java/Spring

[JUnit] fail() : Ambiguous method call. Both 에러

1984 2023. 4. 11. 10:00

에러

Springboot 에서 Test case 작성 중 fail() 메소드 사용 할 때 에러가 발생하였다.

import static org.assertj.core.api.Assertions.*;
import static org.junit.jupiter.api.Assertions.*;

fail("에러가 발생해야 합니다.");
Ambiguous method call. Both

원인

동일한 이름을 가진 method가 중복 되어서 발생한 에러.

두 개의 Assertions 가 모두 static으로 import 되어 있어서 발생하였다.

해결

import static org.assertj.core.api.Assertions.*;
import static org.junit.jupiter.api.Assertions.*;

org.assertj.core.api.Assertions.fail("에러가 발생해야 합니다.");

 

728x90