Using spring boot 3.0.0 and the following spock dependencies:

              <dependency>
            <groupId>org.apache.groovy</groupId>
            <artifactId>groovy</artifactId>
            <version>4.0.6</version>
            <type>pom</type>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.spockframework</groupId>
            <artifactId>spock-core</artifactId>
            <version>2.3-groovy-4.0</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.spockframework</groupId>
            <artifactId>spock-spring</artifactId>
            <version>2.3-groovy-4.0</version>
            <scope>test</scope>
        </dependency>

sampleTestIT.groovy test class:

package com.example.spocktest

import org.spockframework.util.Assert
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.test.context.SpringBootTest
import org.springframework.boot.test.web.client.TestRestTemplate
import spock.lang.Specification

@SpringBootTest(classes = [SpockTestApplication])
class sampleTestIT extends Specification {
    @Autowired
    TestRestTemplate testRestTemplate

    @Autowired
    SampleService sampleService;

    def 'app context'() {
        expect:
        Assert.notNull(testRestTemplate)
    }

    def 'app context2'() {
        expect:
        Assert.notNull(sampleService)
    }
}

Output:

Condition failed with Exception:

Assert.notNull(testRestTemplate)
|      |       |
|      |       null
|      org.spockframework.util.InternalSpockError: argument is null
|       at org.spockframework.util.Assert.notNull(Assert.java:35)
|       at org.spockframework.util.Assert.notNull(Assert.java:30)
|       at com.example.spocktest.sampleTestIT.app context(sampleTestIT.groovy:19)
class org.spockframework.util.Assert


    at com.example.spocktest.sampleTestIT.app context(sampleTestIT.groovy:19)
Caused by: org.spockframework.util.InternalSpockError: argument is null
    at org.spockframework.util.Assert.notNull(Assert.java:35)
    at org.spockframework.util.Assert.notNull(Assert.java:30)
    ... 1 more


Condition failed with Exception:

Assert.notNull(sampleService)
|      |       |
|      |       null
|      org.spockframework.util.InternalSpockError: argument is null
|       at org.spockframework.util.Assert.notNull(Assert.java:35)
|       at org.spockframework.util.Assert.notNull(Assert.java:30)
|       at com.example.spocktest.sampleTestIT.app context2(sampleTestIT.groovy:25)
class org.spockframework.util.Assert


    at com.example.spocktest.sampleTestIT.app context2(sampleTestIT.groovy:25)
Caused by: org.spockframework.util.InternalSpockError: argument is null
    at org.spockframework.util.Assert.notNull(Assert.java:35)
    at org.spockframework.util.Assert.notNull(Assert.java:30)
    ... 1 more

Comment From: wilkinsona

I'm afraid this is out of Spring Boot's control. Spock's Spring Extension tries to use org.springframework.test.util.MetaAnnotationUtils which was deprecated in Spring Framework 5.3 and has been removed in 6.0. This prevents it from finding the @BootstrapWith annotation with which @SpringBootTest is meta-annotated. You can work around the problem by using @ContextConfiguration directly on your test class. Spock's Spring Extension is able to find this annotation.

This has already been reported to the Spock Team: https://github.com/spockframework/spock/issues/1539.

Comment From: mohankowsu

dependencies are not compatible

Comment From: jamesdh

FWIW, this issue was fixed in spockframework/spock#1541. A formal release has not been made yet that includes it, but you can still get the fix using their 2.4-M1 milestone release. Or you can work around it by simply adding the @ContextConfiguration annotation to your test/spec that @wilkinsona mentioned above. .