(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' <-- ์ด๊ฒ ์๋์ง ํ์ธ
}