Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Oct 25 18:20
    codecov[bot] commented #1380
  • Oct 25 18:19
    codecov[bot] commented #1380
  • Oct 25 18:18
    codecov[bot] commented #1380
  • Oct 25 18:17
    codecov[bot] commented #1380
  • Oct 25 18:16
    codecov[bot] commented #1380
  • Oct 25 18:16
    codecov[bot] commented #1380
  • Oct 25 18:15
    codecov[bot] commented #1380
  • Oct 25 18:11
    codecov[bot] commented #1380
  • Oct 25 18:11
    leonard84 synchronize #1380
  • Oct 25 18:11
    leonard84 review_requested #1386
  • Oct 25 18:11
    leonard84 ready_for_review #1386
  • Oct 25 18:10
    leonard84 review_requested #1387
  • Oct 24 17:44
    codecov[bot] commented #1386
  • Oct 24 17:42
    codecov[bot] commented #1386
  • Oct 24 17:42
    codecov[bot] commented #1386
  • Oct 24 17:41
    codecov[bot] commented #1386
  • Oct 24 17:40
    codecov[bot] commented #1386
  • Oct 24 17:40
    codecov[bot] commented #1386
  • Oct 24 17:40
    codecov[bot] commented #1386
  • Oct 24 17:40
    codecov[bot] commented #1386
woodgiraffe
@woodgiraffe
hi, I'm looking for a way to pass a list of closures that are expected to all throw the same type of exception and verify this behavior without writing feature methods for every single one, I'd welcome any pointers that can put me in the right direction
Alexander Kriegisch
@kriegaex
Please post your code, explain what you tried and what is different from your expectation.
Did you search stackoverflow.com? I answered similar questions there before, even very recently.
Simon Temple
@simon-temple

Hi all, I have a newbie question about Script bindings... I am running a test via the EmbeddedSpecRunner()

import spock.util.EmbeddedSpecRunner
def esr = new EmbeddedSpecRunner()
esr.runClass(SpockTestClass.class)

This is my groovy Script class. Before I run my Script I bind an instance of a class called myDsl to it.
I would like to use myDsl from within SpockTestClass but cannot figure out a way to supply it via the EmbeddedSpecRunner
I have tried creating a @Singleton and referencing it from within the Specification but I'm guessing classloaders stop me seeing this externally created .instance
How can I supply a pre-built Object(s) for use within a Specification?

Alexander Kriegisch
@kriegaex
@simon-temple, maybe someone more "groovy" than I can make sense of this snippet out of context, but as far as I am concerned, I would be glad to see the full picture. Could you please provide the test and, if necessary to run it, also a class under test? I just need the tiniest versions of both which reproduce your problem, then I can look into it. I would like to understand what you mean exactly by "bind an instance". Bind how? Bind where?
Simon Temple
@simon-temple

@kriegaex, thank you for looking at this... the code snippet is an instance of the Groovy Script class which has a set/get Binding method (https://docs.groovy-lang.org/latest/html/api/groovy/lang/Script.html) Before I run the Script I add an object called myDsl via a Binding (https://docs.groovy-lang.org/latest/html/api/groovy/lang/Binding.html). For example, myDsl has a log() method so I can do this:

import spock.util.EmbeddedSpecRunner
def esr = new EmbeddedSpecRunner()
myDsl.log("About to run the test")
esr.runClass(SpockTestClass.class)

However I cannot access the Binding of the Script from within my SpockTestClass as I cannot find a way to pass any pre-instantiated object into a test when using the EmbeddedSpecRunner(). I think the Binding is perhaps confusing my question. A simpler question might be :

import spock.util.EmbeddedSpecRunner

def esr = new EmbeddedSpecRunner()

def myMap = [:]
myMap['hello'] = 'world'

esr.runClass(SpockTestClass.class)

The test class looks like:

import spock.lang.*

class SpockTestClass extends Specification {

    def "hello must be world"() {
        given:
        def value = myMap['hello']

        expect:
        value == 'world'
    }
}

The results are:

groovy.lang.MissingPropertyException: No such property: myMap for class: io.platform6.app.core.scripts.rd_spockmain.SpockTestClass
    at SpockTestClass.hello must be world(SpockTestClass:10)

How can I supply a pre-built Object(s) for use within a Specification?

Alexander Kriegisch
@kriegaex

Ugh, that's ugly, depending on a binding not present in the spec itself during feature execution. But I understand what you are trying to do. I know that my recommendation not to do it like that, because the test also cannot run stand-alone like that and forever depends on the calling script, does not solve your problem. The Groovy guys like Leonard and Bjรถrn probably know if and how this can be achieved.

My recommendation would be to fetch the values you need in a where: block, maybe using a custom data provider. You can read them from a file, a database, a website or wherever.

Simon Temple
@simon-temple
Yes I take your point, relying on external side-effects is not a good unit testing approach. However, I'm trying to push the use of Spock a little further and introduce its use as a functional testing tool. To do this I'd like to execute the tests within a provided environment (with some pre instantiated objects). Perhaps I'm trying to use Spock in a way it was not designed for?
Simon Temple
@simon-temple

BTW: I found an example using Spring:

class SampleSpringSpec extends Specification {
       @Autowired
        private WebController webController
        def "when context is loaded then controller bean is created"() {
               expect: "the WebController is created"
               webController != null
       }
}

Maybe I need to look at developing our version of the Autowire annotation ?

Alexander Kriegisch
@kriegaex
The Spock manual has chapters on annotation-driven as well as global Spock extensions. They are quite powerful. I am not an expert extension developer, but have used both before and can help a bit, if you have any problems. I am still struggling to understand what you are trying to achieve, because you are mostly explaining how you want to do it, instead of explaining what you want to achieve. Why would using Spock as a "functional testing tool" require you to work like this, and what does the term mean for you? I think we are having an XY problem here.
Alexander Kriegisch
@kriegaex
Besides, did you try to extend EmbeddedSpecification and compile your tests on the fly from strings? That way you could easily wire in values into the source code, instead of binding variables. Maybe that is enough for your purposes, I am not sure. There are dozens of exaples in Spock's test harness, e.g. in the smoke tests section. One random example would be:
https://github.com/spockframework/spock/blob/master/spock-specs/src/test/groovy/org/spockframework/smoke/condition/DiffedObjectRendering.groovy
Ligun
@ligun

Hi, I test my library with Spock Framework.
I could built the test a few days ago, but yesterday suddenly it doesn't work normally.
gradle test returns success, but the report file is written as no test item.

buildf file is blow

plugins {
    id 'groovy'
}

archivesBaseName = 'project'
group = 'group'
version = '1.0'

repositories {
    mavenCentral()
}

dependencies {
    implementation 'org.codehaus.groovy:groovy:3.0.8'
    testImplementation 'org.spockframework:spock-core:2.0-groovy-3.0'
}

I haven't changed anything.
It used to work fine.

Does anyone have an advice about it?

Ligun
@ligun

I resolved it.
I forgot that I changed spock version to 2.0.
It seems to add the setting test { userJUnitPlatform() } to build.gradle.
After changed, it succeed to discover the test under test directory.

Do I have to add this settings when I use Spock 2.0?

Alexander Kriegisch
@kriegaex

@ligun, the Spock manual's Getting started section links to an example project which contains both Maven and Gradle configurations. If you look at the Gradle config, you are going to find useJUnitPlatform() there.

The Spock 2.0 release notes also state in the very first line of "highlights":

Spock is now a test engine based on the JUnit Platform

Ligun
@ligun
Thank you for your reply.
I understood now.
Alexander Kriegisch
@kriegaex
Very welcome. ๐Ÿ™‚ Happy testing!
gaurav77
@gaurav77:matrix.org
[m]
Hello everyone. I am new to Spock and am trying to find if there are any active ore up-to-date extension projects that integrate Spock with gherkin feature files/directories, for e.g creating/validating Spock tests against gherkin files. I found two projects like these, but they are quite old and are not actively maintained: https://pease.github.io/ and https://github.com/davidmc24/spock-gherkin-poc
Alexander Kriegisch
@kriegaex
None that I am aware of, but actually I never felt the need or did any research, because Spock is a BDD tool already. I do admit that I never used Gherkin before, simply because I met Spock first and have been happy with it ever since. What is your use case?
12 replies
gaurav77
@gaurav77:matrix.org
[m]
Thanks Alexander. Interesting perspective. Cut out the extra step. Have the non-technical people write the test spec themselves. What plug-in did you use with jira. Was it XRay?
Slightly different topic: what do you think are the most powerful advantages of Spock over Cucumber which also follows the โ€˜given, when, then โ€˜ approach?
gaurav77
@gaurav77:matrix.org
[m]
Sure, Alexander. Thanks for your help.
MAXIM GOLOTA
@golotamaxim
Hello everyone. I try to test my service class as subject with some collaborators. In my service class some method supposes to use Util class with static method. How can I mock this static method and provide different results for different test cases?
3 replies
stansvec
@stansvec:matrix.org
[m]
Anyone else experiences: java.lang.Exception: No runnable methods when running a spock test in the newest IDEA version 2021.2?
Alexander Kriegisch
@kriegaex
@stansvec:matrix.org, no. I think it would be helpful for you to be more specific.
stansvec
@stansvec:matrix.org
[m]

I upgraded IDEA to the newest version and then when I run any spock test (whole class or individual methods) I get this error in the test console:

java.lang.Exception: No runnable methods

    at org.junit.runners.BlockJUnit4ClassRunner.validateInstanceMethods(BlockJUnit4ClassRunner.java:191)
    at org.junit.runners.BlockJUnit4ClassRunner.collectInitializationErrors(BlockJUnit4ClassRunner.java:128)
    at org.junit.runners.ParentRunner.validate(ParentRunner.java:416)
    at org.junit.runners.ParentRunner.<init>(ParentRunner.java:84)
    at org.junit.runners.BlockJUnit4ClassRunner.<init>(BlockJUnit4ClassRunner.java:65)
    at org.junit.internal.builders.JUnit4Builder.runnerForClass(JUnit4Builder.java:10)
    at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
    at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:26)
    at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
    at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:33)
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:50)
    at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:33)
    at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:235)
    at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:54)

Was just wondering if this is somehow specific to my setup or a new general bug

Alexander Kriegisch
@kriegaex
When I said "be more specific", I was actually talking about an MCVE rather than a call stack without any code.
Alexander Kriegisch
@kriegaex
@stansvec:matrix.org: I just saw a similar problem in IDEA 2021.2 when running some tests in a Spock 2 project. Some tests run in IDEA, others do not. I cannot see a pattern yet. In Maven, all tests run,so it is an IDEA problem. What puzzles me is the JUnit 4 stuff in the stack trace. Spock 2 tests run on the JUnit 5 platform.
1 reply
Alexander Kriegisch
@kriegaex
I created https://youtrack.jetbrains.com/issue/IDEA-275517. Let us wait and see what the JetBrains people say.
Alexander Kriegisch
@kriegaex
BTW, I noticed so many bugs and breaking changes in 2021.2, I think it is the worst update in a long time. I think, I created 3 different IDEA issues in the last 24 hours alone.
stansvec
@stansvec:matrix.org
[m]
Thanks for taking care of this!
Hope it won't take too long for them to fix it
I've noticed declining stability/quality with every new IDEA release for a while and it's getting quite worrying
Also found more issues with the newest one (no spock related)..
Alexander Kriegisch
@kriegaex

I have a problem with this kind of test:

package de.scrum_master.stackoverflow

import de.jodamob.kotlin.testrunner.OpenedClasses
import de.jodamob.kotlin.testrunner.OpenedPackages
import de.jodamob.kotlin.testrunner.SpotlinTestRunner
import org.junit.runner.RunWith
import org.spockframework.util.VersionNumber
import spock.lang.IgnoreIf
import spock.lang.Specification
import spock.lang.Unroll

/**
 * See https://stackoverflow.com/q/48391716/1082681
 * See https://github.com/dpreussler/kotlin-testrunner
 */
@RunWith(SpotlinTestRunner)
@OpenedClasses(FinalClass)
//@OpenedPackages("de.scrum_master.stackoverflow")
@IgnoreIf({
  // de.jodamob.kotlin.testrunner.NoMoreFinalsClassLoader uses Javassist which tries to make
  // protected java.lang.ClassLoader.defineClass accessible. Due to JEP-396, this is forbidden since JDK 16.
  VersionNumber.parse(jvm.javaSpecificationVersion).major >= 16
})
class AnotherClassSpotlinRunnerTest extends Specification {
  def "use SpotlinRunner to stub final method in final class"() {
    given:
    FinalClass finalClass = Stub() {
      finalMethod() >> "mocked"
    }

    expect:
    new AnotherClass().doSomething(finalClass) == "mocked"
  }
}

The problem is that @IgnoreIf is evaluated too late for this case, because the error already occurs in the SpotlinTestRunner. I am looking for a way to keep this test in my Spock 1.3 playground project for reference, because up to JDK 15 is runs fine. Is there a way to stop a Spock (JUnit 4) test from running based on a condition, before the runner specified by @RunWith is excecuted?

Alexander Kriegisch
@kriegaex
Sorry, I made a copy & paste error with my previous post. Again:

I tried several things before, such as

Both are executed too late in the lifecycle, i.e. they are unable to prevent the SpotlinTestRunner from being initialised.

Actually, the runner has not been updated since version 0.3.1 in 2016, i.e. it knows nothing about JEP-396 and strong JDK encapsulation. The best solution would be for it to be upgraded by its author. My workaround for now is to replace the runner by a delegate, which I named JEP396AwareSpotlinTestRunner. It either passes through every method call to a SpotlinTestRunner or makes sure that all test executions are ignored in order to get correct test reporting.

package de.scrum_master.testing

import de.jodamob.kotlin.testrunner.SpotlinTestRunner
import org.junit.runner.Description
import org.junit.runner.manipulation.Filter
import org.junit.runner.manipulation.NoTestsRemainException
import org.junit.runner.manipulation.Sorter
import org.junit.runner.notification.RunNotifier
import org.junit.runners.model.InitializationError
import org.spockframework.runtime.Sputnik

class JEP396AwareSpotlinTestRunner extends Sputnik {
  private static final int javaMajor = Integer.parseInt(System.properties.getProperty("java.version").split("[.]")[0])
  public static final boolean hasJEP396 = javaMajor >= 16

  private static final Filter ignoreAllFilter = new Filter() {
    @Override
    boolean shouldRun(Description description) { return false }

    @Override
    String describe() { return "ignores all tests" }
  }

  private final Sputnik sputnik

  JEP396AwareSpotlinTestRunner(Class<?> clazz) throws InitializationError {
    super(clazz)
    sputnik = hasJEP396 ? this : new SpotlinTestRunner(clazz)
  }

  @Override
  void filter(Filter filter) throws NoTestsRemainException {
    if (hasJEP396)
      super.filter(ignoreAllFilter)
    else
      sputnik.filter(filter)
  }

  @Override
  void run(RunNotifier notifier) {
    if (hasJEP396)
      super.run(notifier)
    else
      sputnik.run(notifier)
  }

  @Override
  Description getDescription() {
    if (hasJEP396)
      return super.getDescription()
    else
      return sputnik.getDescription()
  }

  @Override
  void sort(Sorter sorter) {
    if (hasJEP396)
      super.sort(sorter)
    else
      sputnik.sort(sorter)
  }
}

The Spock spec still needs an @IgnoreIf or @Requires in addition to @RunWith(JEP396AwareSpotlinTestRunner), but otherwise no changes are required. It can even utilise a constant JEP396AwareSpotlinTestRunner.hasJEP396 for its own condition:

package de.scrum_master.stackoverflow

import de.jodamob.kotlin.testrunner.OpenedClasses
import de.jodamob.kotlin.testrunner.OpenedPackages
import de.scrum_master.testing.JEP396AwareSpotlinTestRunner
import org.junit.runner.RunWith
import spock.lang.IgnoreIf
import spock.lang.Specification

/**
 * See https://stackoverflow.com/q/48391716/1082681
 * See https://github.com/dpreussler/kotlin-testrunner
 */
@RunWith(JEP396AwareSpotlinTestRunner)
@IgnoreIf({ JEP396AwareSpotlinTestRunner.hasJEP396 })
@OpenedClasses(FinalClass)
//@OpenedPackages("de.scrum_master.stackoverflow")
class AnotherClassSpotlinRunnerTest extends Specification {
  def "use SpotlinRunner to stub final method in final class"() {
    given:
    FinalClass finalClass = Stub() {
      finalMethod() >> "mocked"
    }

    expect:
    new AnotherClass().doSomething(finalClass) == "mocked"
  }
}
Alexander Kriegisch
@kriegaex

See dpreussler/kotlin-testrunner#27.

Thanks all for listening to me talking to myself. But if I ask the community a question and find an answer, I think it is only fair to share it.

Peter Guo
@mushanzi1216
hello anyone knows how to mock a generic class
Alexander Kriegisch
@kriegaex
@mushanzi1216, please learn how to ask better questions, e.g. read this article. Then try again here, asking a question with enough detail to answer in a meaningful way.
What I mean is: Your question is not unlike "Does anyone know how to drive a car?" and then someone saying "yeah, sure". It would be the correct answer, but not helpful to the person asking.
treethingy
@treethingy
Hi, I'm looking for a sophisticated way to modify the way "Condition not satisfied:" output is rendered. I'm validating XML agains XSD and Schematron. I've created a hamcrest matcher and implemented "describeMismatch". Is there a better way to do it?
3 replies
liubo404
@liubo404
Error:Groovyc: While compiling tests of iceim: Could not instantiate global transform class org.spockframework.compiler.SpockTransform specified at jar:file:/home/ben/.m2/repository/org/spockframework/spock-core/2.0-groovy-3.0/spock-core-2.0-groovy-3.0.jar!/META-INF/services/org.codehaus.groovy.transform.ASTTransformation  because of exception java.lang.NullPointerException
how to resolve this error, any ideas, thanks a lot
I google for an hour, nothing useful can help~
the maven dependency below:
    <dependency>
            <groupId>org.spockframework</groupId>
            <artifactId>spock-core</artifactId>
            <version>2.0-groovy-3.0</version>
            <scope>test</scope>
        </dependency>

  <plugin>
                <groupId>org.codehaus.gmavenplus</groupId>
                <artifactId>gmavenplus-plugin</artifactId>
                <version>1.12.1</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>compile</goal>
                            <goal>compileTests</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.22.2</version>
                <configuration>
                    <useFile>false</useFile>
                    <includes>
                        <include>**/*Spec.java</include>
                    </includes>
                </configuration>
            </plugin>
้™†้พŸ
@xialugui
@liubo404 ่ฏ•่ฏ•ๆ˜พ็คบๆŒ‡ๅฎšgroovy็‰ˆๆœฌ
<!-- https://mvnrepository.com/artifact/org.codehaus.groovy/groovy-all -->
<dependency>
    <groupId>org.codehaus.groovy</groupId>
    <artifactId>groovy-all</artifactId>
    <version>3.0.8</version>
    <type>pom</type>
</dependency>
liubo404
@liubo404
image.png
@xialugui ๅฅฝ่ฑก่ฟ˜ๆ˜ฏไธๅคช่กŒ, ๅคš่ฐข~
Alexander Kriegisch
@kriegaex

@xialugui, groovy-all is not necessary for Spock 2.0.

@liubo404 , it is hard to reason about a partial POM without any code. Please be so kind as to share a reproducer on GitHub. This is called an MCVE. It helps us to understand and analyse your problem and you to get the answers you need.

liubo404
@liubo404
I think it's my problem, I used spock with spring-boot 2.4.4, that's why this error occurs.
thanks very much @kriegaex
I commit this to github issue, and close it.
spockframework/spock-example#44
โ”œโ”€โ”€ pom.xml     //1.here inherit from spring-boot-starter-parent
โ”œโ”€โ”€ README.md
โ””โ”€โ”€ spocky
    โ”œโ”€โ”€ pom.xml //2.spock depency 
    โ”œโ”€โ”€ spocky.iml
    โ””โ”€โ”€ src
        โ”œโ”€โ”€ main
        โ”‚   โ”œโ”€โ”€ java
        โ”‚   โ””โ”€โ”€ resources
        โ””โ”€โ”€ test
            โ”œโ”€โ”€ groovy
            โ”‚   โ””โ”€โ”€ com
            โ”‚       โ””โ”€โ”€ abc
            โ”‚           โ””โ”€โ”€ DemoSpec.groovy
            โ””โ”€โ”€ java
                โ””โ”€โ”€ DemoTest.java

//1.pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.4.4</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>

    <groupId>com.abc</groupId>
    <artifactId>demo-parent</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>xxxx</name>
    <description>xxx</description>
    <packaging>pom</packaging>

    <modules>
        <module>spocky</module>
    </modules>
</project>


//2.spock depency pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <parent>
        <artifactId>internal-control-parent</artifactId>
        <groupId>com.abc</groupId>
        <version>0.0.1-SNAPSHOT</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>

    <artifactId>spocky</artifactId>

    <dependencies>
        <dependency>
            <groupId>org.spockframework</groupId>
            <artifactId>spock-core</artifactId>
            <version>2.0-groovy-3.0</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.spockframework</groupId>
            <artifactId>spock-spring</artifactId>
            <version>2.0-groovy-3.0</version>
            <scope>test</scope>
        </dependency>
   <!--
        with this or not, still the same ERROR:Groovyc....
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <version>2.5.0</version>
            <scope>test</scope>
        </dependency>

    --> 

    </dependencies>


    <build>
        <plugins>
            <plugin>
                <groupId>org.codehaus.gmavenplus</groupId>
                <artifactId>gmavenplus-plugin</artifactId>
                <version>1.12.1</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>compile</goal>
                            <goal>compileTests</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.22.2</version>
                <configuration>
                    <useFile>false</useFile>
                    <includes>
                        <include>**/*Spec.java</include>
                    </includes>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>


//3.DemoSpec.groovy

package com.abc;

import spock.lang.Specification

class DemoSpec extends Specification {
    def "an integer can be incremented"() {
        given:
        int i = 1
        when:
        i++
        then:
        i == 2
    }
}
liubo404
@liubo404
finally, I change the spock-core version to 2.0-groovy-2.5, it's solve the problem
//2.spock depency pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <parent>
        <artifactId>internal-control-parent</artifactId>
        <groupId>com.ctjsoft</groupId>
        <version>0.0.1-SNAPSHOT</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>

    <artifactId>spocky</artifactId>

    <dependencies>
        <dependency>
            <groupId>org.spockframework</groupId>
            <artifactId>spock-core</artifactId>
            <version>2.0-groovy-2.5</version>
            <scope>test</scope>
        </dependency>
    </dependencies>


    <build>
        <plugins>
            <plugin>
                <groupId>org.codehaus.gmavenplus</groupId>
                <artifactId>gmavenplus-plugin</artifactId>
                <version>1.12.1</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>compile</goal>
                            <goal>compileTests</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.22.2</version>
                <configuration>
                    <useFile>false</useFile>
                    <includes>
                        <include>**/*Spec.java</include>
                    </includes>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>
XIA YUN
@unxia
Hi, I'm looking for a way to inject spring bean into spock interceptor to prepare data , kind of like https://github.com/janbols/spock-dbunit, but using spring to do it
Alexander Kriegisch
@kriegaex
@liubo404, oh, you cross-posted from a Spock issue. In that case, a link would have suficed, no need to copy & paste everything here. Anyway, I am happy you solved your build configuration problem. Of course, you canot combine Groovy 3 with Spock for Groovy 2.5 or the other way around. You need to use the Groovy and Spock artifacts which match with each other. In your case, you chose to keep Groovy 2.5 and adjust Spock to it. The other way would have been to upgrade to Groovy 3.