(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'  <-- ์ด๊ฒŒ ์žˆ๋Š”์ง€ ํ™•์ธ
}