> Task :test FAILED
Execution failed for task ':test'.
> No tests found for given includes: [com.example.jpabook.service.MemberServiceTest](--tests filter)
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.
Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0.
You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
For more on this, please refer to https://docs.gradle.org/8.5/userguide/command_line_interface.html#sec:command_line_warnings in the Gradle documentation.
BUILD FAILED in 2s
4 actionable tasks: 2 executed, 2 up-to-date
Execution failed for task ':test'.
> No tests found for given includes: [com.example.jpabook.service.MemberServiceTest](--tests filter)
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.
Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0.
You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
For more on this, please refer to https://docs.gradle.org/8.5/userguide/command_line_interface.html#sec:command_line_warnings in the Gradle documentation.
BUILD FAILED in 2s
4 actionable tasks: 2 executed, 2 up-to-date
문제상황
테스트 코드가 갑자기 오류가 난다.
이 오류는 Gradle이 테스트를 찾지 못해서 발생하는 것으로 보입니다. 주어진 테스트 클래스인 OrderServiceTest가 Gradle에 의해 실행되지 않았기 때문입니다.
라고 하는데, 분명 코드에는 문제가 없어서 원인불명이었는데, import부분을 확인하고 원인을 알 수 있었다.
해결
import org.junit.jupiter.api.Test; 대신
import org.springframework.boot.test.context.SpringBootTest;
를 사용해야 한다. 첫번째 jupiter을 사용했기 때문에 생기는 오류였다.
결론
import org.junit.Test;를 사용하지 말고 import org.springframework.boot.test.context.SpringBootTest;를 사용해야한다.
테스트 코드에는 오류가 없는데 빌드 오류가 난다. -> import패키지 경로가잘못됐 가능성이 있다.