(SpringBoot3 + Correto 17 (java 17) 환경에서 spock test 시 발생한
TestEngine with ID 'spock' failed to discover tests 오류 해결방안 공유합니다.
IntelliJ 에서 Spring Initializer를 이용하여
스프링부트3 + 자바 17 기반의 신규 프로젝트를 생성,
빌드가 정상적으로 되는지 확인 후
spock 테스트를 위한 라이브러리를 아래 3개 추가했습니다.
testImplementation 'org.spockframework:spock-core:2.4-M1-groovy-4.0'
testImplementation 'org.spockframework:spock-spring:2.4-M1-groovy-4.0'
testImplementation 'org.apache.groovy:groovy-all:4.0.13'
그리고 샘플 테스트 클래스를 만들었습니다.
class SampleSpec extends Specification {
def "where with variables: #size"() {
when:
def list = new ArrayList(size)
then:
list.size() == 0
where:
size << [1, 2, 3, 4, 5]
}
def "using data tables for calculating max, Max of #a and #b is #max"() {
expect:
Math.max(a, b) == max
where:
a | b || max
1 | 2 || 2
7 | 4 || 7
0 | 0 || 0
}
}
실행을 해보았더니 아래와 같은 에러가 발생했습니다.
Internal Error occurred.
org.junit.platform.commons.JUnitException: TestEngine with ID 'spock' failed to discover tests
...중략...
Caused by: org.junit.platform.commons.JUnitException: ClassSelector [className = 'com.project.SampleSpec', classLoader = null] resolution failed
...중략...
Caused by: org.junit.platform.commons.PreconditionViolationException: Could not load class with name: com.project.SampleSpec
...중략...
Caused by: java.lang.ClassNotFoundException: com.project.SampleSpec
구글링 결과 build.gradle 파일의 plugins 에 id 'groovy' 를 추가해주면 되는 문제였습니다.
plugins {
id 'java'
id 'org.springframework.boot' version '3.2.1'
id 'io.spring.dependency-management' version '1.1.4'
id 'groovy' <-- 이게 있는지 확인
}
[IntelliJ] 신규 생성 프로젝트의 빌드 오류 (Could not resolve org.springframework.boot:spring-boot-gradle-plugin:3.2.1) (1) | 2024.01.03 |
---|---|
SpringBoot 2.3 -> 2.5 업그레이드 후기 (0) | 2023.12.29 |
[AWS/SQS] cloudwatch datapoint 조회하기 (2) | 2022.12.29 |
MariaDB로 AWS Aurora 연동시 readOnly 트랜잭션이 writer 쪽에서 실행되는 현상 분석 (0) | 2022.12.26 |
[AWS] redis-cli 를 이용한 elasticache 데이터 조회 (0) | 2022.05.27 |