Skip to content

Add spring7 tests#2262

Merged
Vampire merged 4 commits intomasterfrom
spring7-test
Mar 28, 2026
Merged

Add spring7 tests#2262
Vampire merged 4 commits intomasterfrom
spring7-test

Conversation

@Vampire
Copy link
Copy Markdown
Member

@Vampire Vampire commented Nov 14, 2025

Summary by CodeRabbit

  • New Features

    • Added a Spring 7 test module with Java 17 toolchain and new tests verifying Spring integration and runtime compatibility.
  • Bug Fixes

    • Broadened detection of injection/resource annotations to include Jakarta variants to avoid false-positive shared-field errors.
  • Chores

    • Expanded Spring/Java compatibility matrix, added Jakarta injection API, standardized dependency notation, disabled certain test compilation tasks, and included the new test module in the build.

Copy link
Copy Markdown
Member Author

Vampire commented Nov 14, 2025

This stack of pull requests is managed by Graphite. Learn more about stacking.

@codecov
Copy link
Copy Markdown

codecov bot commented Nov 14, 2025

Codecov Report

❌ Patch coverage is 0% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.15%. Comparing base (8d380cc) to head (75ddaa1).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
...ava/org/spockframework/spring/SpringExtension.java 0.00% 3 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##             master    #2262      +/-   ##
============================================
- Coverage     82.16%   82.15%   -0.01%     
- Complexity     4822     4823       +1     
============================================
  Files           472      472              
  Lines         15036    15038       +2     
  Branches       1905     1907       +2     
============================================
+ Hits          12354    12355       +1     
- Misses         1989     1991       +2     
+ Partials        693      692       -1     
Files with missing lines Coverage Δ
...ava/org/spockframework/spring/SpringExtension.java 47.61% <0.00%> (-1.57%) ⬇️

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@@ -0,0 +1,34 @@
def springVersion = "7.0.0"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't it be good to move the version into the libs.versions.toml, and use it there in a dependency, just do make it updateable via renovate, something like spring7Versionsimilar to junit?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe?
Here I just copied the spring6 tests as they are and made them be spring7 tests.
I'd say such a polishing could be a separate PR?

Comment thread spock-spring/spring7-test/spring7-test.gradle Outdated

testImplementation projects.spockCore
testImplementation projects.spockSpring
testImplementation libs.junit4
Copy link
Copy Markdown
Member

@AndreasTu AndreasTu Nov 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you use Junit4 here?
Is it due to the SpringRunnerTest?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have no idea. -:-D
I just copied the spring6 to spring7 and the boot3 to boot4, changed the packages and made the adjustments to make them run.
So everything you said in both PRs is probably valid (didn't look in detail yet) but also for the existing projects.

@AndreasTu
Copy link
Copy Markdown
Member

There is also the new version missing in spock-spring\spring.gradle, where there is a Set of versions to test.

@AndreasTu
Copy link
Copy Markdown
Member

AndreasTu commented Nov 15, 2025

When I execute gradlew :spock-spring:check locally with Java 21, it already fails for the task spring6Test, but it works with Java 17.

It seams that there is already a regression with Java 21 and spring 6:

org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type 'org.spockframework.spring.Service2' available: expected single matching bean but found 4: org.spockframework.spring.Service2#0,org.spockframework.spring.Service2#1,org.spockframework.spring.Service2#2,aName

https://ge.spockframework.org/s/f5cvzjnfzd3da

Note: I also needed to adapt the line in spring.gradle to "6.0.0": (17..21),

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Jan 4, 2026

📝 Walkthrough

Walkthrough

Adds a Spring 7 test module with tests and configs, updates Spring-version matrix and Gradle/groovy settings, extends injection handling to Jakarta annotations, includes the new module in non-2.5 settings, and performs small Gradle DSL syntax tweaks in existing test modules.

Changes

Cohort / File(s) Summary
Settings
settings.gradle
Include spock-spring:spring7-test in the non-2.5 variant branch.
Gradle syntax cleanup
spock-spring/spring3-test/spring3-test.gradle, spock-spring/spring5-test/spring5-test.gradle, spock-spring/spring6-test/spring6-test.gradle
Remove parentheses around testImplementation dependency strings (syntax-only).
Spring 7 build
spock-spring/spring7-test/spring7-test.gradle
Add new Spring 7 test module: pin springVersion (7.0.6), Java 17 toolchain, JavaCompile encoding, version resolution rule, and dependencies (Spring, Spock, JUnit4).
Spring 7 tests & configs
spock-spring/spring7-test/src/test/groovy/org/spockframework/spring7/NoMockConfig.groovy, .../TestConfig.groovy, .../ServiceExecutor*, .../RuntimeCompatibilitySpec.groovy, .../SpringBeanTest.groovy, .../SpringRunnerTest.java
Add TestConfig and NoMockConfig, ServiceExecutor helper, Spock specs and a JUnit4 SpringRunner smoke test exercising injection and bean replacement via @SpringBean.
Spring matrix & Groovy compile
spock-spring/spring.gradle
Expand testSpringVersions (add 7.0.6, widen Java range for 6.x), add jakarta.inject dependency, set GroovyCompile parameters, and disable test compilation tasks via enabled = false.
Spring extension runtime checks
spock-spring/src/main/java/org/spockframework/spring/SpringExtension.java
Treat jakarta.annotation.Resource and jakarta.inject.Inject like their javax.* counterparts when checking disallowed @Shared field injection.
Test annotations compatibility updates
spock-spring/src/test/groovy/org/spockframework/spring/...
spock-spring/src/test/groovy/org/spockframework/spring/docs/MockExamples.groovy, .../MockInjectionExample.groovy, InjectionExamples.groovy, SharedFieldsInjection.groovy, ContextHierarchyExample.groovy, mock/.../SpringSpyWithAopProxyTests.groovy, mock/ComplexUsageSpec.groovy
Update imports and add Javax* aliases while importing Jakarta counterparts; tests now exercise both javax.* and jakarta.* annotation variants (@Named, @Inject, @Resource).

Sequence Diagram(s)

sequenceDiagram
    participant Test as Test (Spock / JUnit)
    participant Spring as Spring Context
    participant Service as ServiceExecutor
    participant Exec as ExecutorService
    participant Future as Future

    Test->>Spring: load `@ContextConfiguration` (NoMockConfig / TestConfig)
    Spring->>Service: instantiate ServiceExecutor (inject ExecutorService)
    Test->>Service: invoke exec()
    Service->>Exec: submit Callable
    Exec->>Future: return Future
    Future->>Service: get() -> result
    Service-->>Test: return result
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~23 minutes

Suggested reviewers

  • AndreasTu

Poem

🐰 I hopped into Spring seven's glade,
Beans replaced and mocks were made,
Java seventeen keeps me spry,
Tests run fast beneath the sky,
A rabbit cheers — the green builds played!

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title 'Add spring7 tests' clearly and concisely summarizes the main objective of the changeset, which is to introduce Spring 7 testing support to the spock-spring module.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch spring7-test

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

♻️ Duplicate comments (2)
spock-spring/spring7-test/spring7-test.gradle (2)

1-1: Consider moving version to libs.versions.toml for automated updates.

Hardcoding the Spring version here means Renovate/Dependabot won't automatically detect and propose updates. Moving it to libs.versions.toml (similar to other version declarations) would enable automated dependency management.


21-21: JUnit 4 dependency usage was questioned in prior review.

A previous reviewer asked why JUnit 4 is used here. This may be intentional if testing SpringRunner compatibility, but worth confirming if JUnit 5 (Jupiter) would be more appropriate for Spring 7.

🧹 Nitpick comments (2)
spock-spring/spring7-test/spring7-test.gradle (1)

3-14: Redundant toolchain configuration.

The java.toolchain block (lines 3-7) already configures Java 17. The tasks.withType(JavaCompile) block (lines 9-14) redundantly sets the same languageVersion. The encoding configuration is valid, but the compiler version is duplicative.

🔎 Suggested simplification
 java {
   toolchain {
     languageVersion = JavaLanguageVersion.of(17)
   }
 }

 tasks.withType(JavaCompile).configureEach {
-  javaCompiler = javaToolchains.compilerFor {
-    languageVersion = JavaLanguageVersion.of(17)
-  }
   options.encoding = 'UTF-8'
 }
spock-spring/spring7-test/src/test/groovy/org/spockframework/spring7/NoMockConfig.groovy (1)

9-10: Consider adding @Configuration annotation.

While Spring may detect the @Bean methods through component scanning or explicit @ContextConfiguration usage, adding the @Configuration annotation makes the intent explicit and is the conventional pattern.

🔎 Suggested fix
 import groovy.transform.CompileStatic
+import org.springframework.context.annotation.Configuration
 import org.springframework.context.annotation.Bean

 import java.util.concurrent.Callable
 import java.util.concurrent.ExecutorService

 @CompileStatic
+@Configuration
 class NoMockConfig {
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 77d0adb and 1d7cf15.

📒 Files selected for processing (10)
  • settings.gradle
  • spock-spring/spring3-test/spring3-test.gradle
  • spock-spring/spring5-test/spring5-test.gradle
  • spock-spring/spring6-test/spring6-test.gradle
  • spock-spring/spring7-test/spring7-test.gradle
  • spock-spring/spring7-test/src/test/groovy/org/spockframework/spring7/NoMockConfig.groovy
  • spock-spring/spring7-test/src/test/groovy/org/spockframework/spring7/RuntimeCompatibilitySpec.groovy
  • spock-spring/spring7-test/src/test/groovy/org/spockframework/spring7/SpringBeanTest.groovy
  • spock-spring/spring7-test/src/test/groovy/org/spockframework/spring7/SpringRunnerTest.java
  • spock-spring/spring7-test/src/test/groovy/org/spockframework/spring7/TestConfig.groovy
🔇 Additional comments (10)
spock-spring/spring3-test/spring3-test.gradle (1)

8-8: LGTM!

The syntax change aligns with the other dependency declarations in the file, improving consistency.

spock-spring/spring5-test/spring5-test.gradle (1)

10-10: LGTM!

Consistent syntax style with other dependency declarations in this file.

spock-spring/spring6-test/spring6-test.gradle (1)

23-23: LGTM!

Syntax consistency with surrounding dependency declarations.

settings.gradle (1)

107-107: LGTM!

The new Spring 7 test module is correctly added in the non-2.5 variant block, maintaining logical version ordering after spring6-test.

Note: Based on PR comments, ensure that the new Spring version is also added to the set of versions to test in spock-spring/spring.gradle.

spock-spring/spring7-test/src/test/groovy/org/spockframework/spring7/TestConfig.groovy (1)

1-17: LGTM!

Clean Spring configuration using DetachedMockFactory to provide a stubbed Executor bean. The @CompileStatic annotation is a good practice for ensuring type safety.

spock-spring/spring7-test/src/test/groovy/org/spockframework/spring7/SpringRunnerTest.java (1)

16-19: LGTM!

The test serves its purpose of verifying that non-Spock tests using SpringJUnit4ClassRunner execute correctly within the Spring 7 module.

spock-spring/spring7-test/src/test/groovy/org/spockframework/spring7/SpringBeanTest.groovy (1)

1-30: LGTM!

Well-structured Spock specification demonstrating @SpringBean functionality with Spring 7. The test correctly:

  • Uses @ContextConfiguration with NoMockConfig as the base configuration
  • Replaces the ExecutorService bean with a mock via @SpringBean
  • Verifies both the mock interaction and return value
spock-spring/spring7-test/src/test/groovy/org/spockframework/spring7/RuntimeCompatibilitySpec.groovy (1)

1-24: LGTM!

The runtime compatibility spec is appropriately simple for its purpose—verifying that Spring 7 context loading and autowiring work correctly with Spock. The trivial 1 == 1 assertion in the first test is intentional: if the Spring context fails to load, the test will fail before reaching that line.

spock-spring/spring7-test/src/test/groovy/org/spockframework/spring7/NoMockConfig.groovy (1)

25-35: LGTM with minor note on consistency.

The ServiceExecutor class correctly models a service that depends on ExecutorService for the mock replacement test scenario. The exec() method using def return type is acceptable for test code, though an explicit String return type would be slightly more self-documenting.

spock-spring/spring7-test/spring7-test.gradle (1)

28-34: Spring 7 should be added to the test matrix in spock-spring/spring.gradle.

The current testSpringVersions map only includes Spring 4.3.5, 5.0.2, and 6.0.0. To ensure Spring 7 is tested alongside the other versions, add it to the testSpringVersions map with the appropriate Java version constraints (e.g., Java 17+).

Comment on lines +12 to +14
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration
public class SpringRunnerTest {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Search for any context configuration files related to SpringRunnerTest
fd -t f "SpringRunnerTest" spock-spring/spring7-test/

echo "---"
# Also search for any -context.xml files in spring7-test
fd -t f "\-context\.xml$" spock-spring/spring7-test/

echo "---"
# Check what files exist in the test directory structure
fd -t f "\.xml$|\.java$|\.groovy$" spock-spring/spring7-test/src/test | head -20

Repository: spockframework/spock

Length of output: 621


🏁 Script executed:

#!/bin/bash
# Read the SpringRunnerTest.java file to see full class content
cat -n spock-spring/spring7-test/src/test/groovy/org/spockframework/spring7/SpringRunnerTest.java

Repository: spockframework/spock

Length of output: 770


🏁 Script executed:

#!/bin/bash
# Check how other tests configure their Spring context
rg -A 3 "@ContextConfiguration|@SpringBootTest" spock-spring/spring7-test/src/test/groovy/org/spockframework/spring7/ -t groovy -t java

Repository: spockframework/spock

Length of output: 1482


🏁 Script executed:

#!/bin/bash
# Check if there's any base test class or configuration that SpringRunnerTest might inherit from
rg "class SpringRunnerTest|extends|@Configuration" spock-spring/spring7-test/src/test/groovy/org/spockframework/spring7/SpringRunnerTest.java -A 5 -B 5

Repository: spockframework/spock

Length of output: 367


Specify context configuration explicitly.

The @ContextConfiguration annotation has no classes or locations parameter, which is inconsistent with other test classes in the same directory and relies on Spring's default context discovery. Since this test doesn't use any Spring beans, either:

  • Remove @ContextConfiguration if no context is needed, or
  • Specify @ContextConfiguration(classes = {}) to explicitly define an empty context

This prevents reliance on Spring's implicit behavior which may vary across versions or configurations.

🤖 Prompt for AI Agents
In
spock-spring/spring7-test/src/test/groovy/org/spockframework/spring7/SpringRunnerTest.java
around lines 12 to 14, the @ContextConfiguration annotation is empty which
relies on Spring's default context discovery; since this test does not use any
Spring beans, either remove the @ContextConfiguration annotation entirely, or
make the configuration explicit by changing it to @ContextConfiguration(classes
= {}) so the test does not depend on implicit/version-dependent context
discovery.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
settings.gradle (1)

107-107: LGTM! Module inclusion follows the established pattern.

The spring7-test module is correctly placed alongside spring6-test and boot3-test in the non-2.5 variant block, which appropriately requires Java 17+.

Note: Per PR comments from AndreasTu, ensure that spock-spring/spring.gradle is also updated to include Spring 7 in the version mapping. Add "7.0.0": (17..17) to the testSpringVersions map (currently missing Spring 7).

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@settings.gradle` at line 107, Update the Spring version-to-Java mapping in
spock-spring/spring.gradle by adding an entry for Spring 7: locate the
testSpringVersions map and insert the key "7.0.0" with the value (17..17) so
Spring 7 is associated with Java 17 (e.g., add "7.0.0": (17..17) to the
testSpringVersions map).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@settings.gradle`:
- Line 107: Update the Spring version-to-Java mapping in
spock-spring/spring.gradle by adding an entry for Spring 7: locate the
testSpringVersions map and insert the key "7.0.0" with the value (17..17) so
Spring 7 is associated with Java 17 (e.g., add "7.0.0": (17..17) to the
testSpringVersions map).

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 3188ea99-7f97-463f-b647-4faa8380e0d9

📥 Commits

Reviewing files that changed from the base of the PR and between 1d7cf15 and 667a845.

📒 Files selected for processing (10)
  • settings.gradle
  • spock-spring/spring3-test/spring3-test.gradle
  • spock-spring/spring5-test/spring5-test.gradle
  • spock-spring/spring6-test/spring6-test.gradle
  • spock-spring/spring7-test/spring7-test.gradle
  • spock-spring/spring7-test/src/test/groovy/org/spockframework/spring7/NoMockConfig.groovy
  • spock-spring/spring7-test/src/test/groovy/org/spockframework/spring7/RuntimeCompatibilitySpec.groovy
  • spock-spring/spring7-test/src/test/groovy/org/spockframework/spring7/SpringBeanTest.groovy
  • spock-spring/spring7-test/src/test/groovy/org/spockframework/spring7/SpringRunnerTest.java
  • spock-spring/spring7-test/src/test/groovy/org/spockframework/spring7/TestConfig.groovy
🚧 Files skipped from review as they are similar to previous changes (7)
  • spock-spring/spring7-test/src/test/groovy/org/spockframework/spring7/NoMockConfig.groovy
  • spock-spring/spring7-test/spring7-test.gradle
  • spock-spring/spring5-test/spring5-test.gradle
  • spock-spring/spring6-test/spring6-test.gradle
  • spock-spring/spring7-test/src/test/groovy/org/spockframework/spring7/SpringRunnerTest.java
  • spock-spring/spring3-test/spring3-test.gradle
  • spock-spring/spring7-test/src/test/groovy/org/spockframework/spring7/TestConfig.groovy

@Vampire
Copy link
Copy Markdown
Member Author

Vampire commented Mar 13, 2026

There is also the new version missing in spock-spring\spring.gradle, where there is a Set of versions to test.

Added

It seams that there is already a regression with Java 21 and spring 6

Also here, I'd say this could / should be a separate PR.
I'm not really fit in spring and boot and here just copied over and adapted the old version so that it runs the same on the new version.

Besides that I did as you said, adding 21 to the upper range and executing spock-spring:check with running Gradle on Java 21 and I got a "build successful".

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@spock-spring/spring.gradle`:
- Around line 16-17: The Spring Java-version map currently pins "6.0.0" and
"7.0.0" to (17..17), which causes the .findAll filter to drop these entries on
JDK 21 and prevents spring6Test/spring7Test variants from being generated;
update the map entries for the keys "6.0.0" and "7.0.0" (in spring.gradle) to a
broader range such as (17..21) so they include Java 21 (or use a dynamic upper
bound that includes the running JDK), ensuring the .findAll on line 18 will keep
those versions.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 11570e0f-c92d-49b0-b8b9-3fa82dc5571f

📥 Commits

Reviewing files that changed from the base of the PR and between 667a845 and 4fc76f3.

📒 Files selected for processing (1)
  • spock-spring/spring.gradle

Comment thread spock-spring/spring.gradle Outdated
@Vampire Vampire force-pushed the spring7-test branch 2 times, most recently from bbb9a75 to 44cffd5 Compare March 13, 2026 16:33
@Vampire
Copy link
Copy Markdown
Member Author

Vampire commented Mar 13, 2026

Also here, I'd say this could / should be a separate PR.
I'm not really fit in spring and boot and here just copied over and adapted the old version so that it runs the same on the new version.

Besides that I did as you said, adding 21 to the upper range and executing spock-spring:check with running Gradle on Java 21 and I got a "build successful".

Ah, old brain.
Of course I have to use -DjavaVersion=, not the version Gradle runs with.
But even then it seems to work for Java 21 and 6.x.
Though it fails even for Java 17 and 7.x. :-(

Actually, with 6.x it works for me for both, 17 and 21.
With 7.x it fails for me with 17 and newer. :-/

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
spock-spring/spring.gradle (1)

16-17: Cap Spring Framework 6.0.x test coverage to Java 21.

Line 16 currently expands automatically to the repo's highest configured JDK (currently 25). Spring Framework 6.0.x officially supports only Java 17–21, so tests may run on JDK 25 where compatibility is not guaranteed by the framework.

Line 17 (Spring 7.0.0) can safely remain uncapped since Spring 7.0.0 officially targets Java 17–25+.

Proposed patch
+def maxTestedSpring6Java = 21
+
 def testSpringVersions = [
   (springVersion): (8..11),
   "5.0.2.RELEASE": (8..11),
-  "6.0.0"        : (17..javaVersions.max()),
+  "6.0.0"        : (17..Math.min(javaVersions.max(), maxTestedSpring6Java)),
   "7.0.0"        : (17..javaVersions.max())
 ].findAll { javaVersion in it.value }.keySet()
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@spock-spring/spring.gradle` around lines 16 - 17, The Spring 6.0.x test
matrix currently uses (17..javaVersions.max()), which expands to the repo's
highest JDK; change the map entry for the key "6.0.0" to use a capped range
(17..21) instead of javaVersions.max() so tests for "6.0.0" only run on Java
17–21; leave the "7.0.0" entry as-is.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@spock-spring/spring.gradle`:
- Around line 16-17: The Spring 6.0.x test matrix currently uses
(17..javaVersions.max()), which expands to the repo's highest JDK; change the
map entry for the key "6.0.0" to use a capped range (17..21) instead of
javaVersions.max() so tests for "6.0.0" only run on Java 17–21; leave the
"7.0.0" entry as-is.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 61b7aa5e-edab-45c0-ac9f-9b05d43a8555

📥 Commits

Reviewing files that changed from the base of the PR and between 44cffd5 and a63018a.

📒 Files selected for processing (1)
  • spock-spring/spring.gradle

@Vampire
Copy link
Copy Markdown
Member Author

Vampire commented Mar 14, 2026

Ah, it was mostly that Spring 7 now only supports jakarta... and no longer javax....

There is only one test left that does not work with Spring 7.
But I'm not sure whether that is an intentional change in Spring 7, a bug in Spring 7, a bug in Spock, whatever.
When resolving the aService2 dependency for service1WithAlias in ComplexUsageSpec it now finds all 4 beans of type Service2 where with previous Spring versions only the one without name, qualifier, and alias was found.

@Vampire
Copy link
Copy Markdown
Member Author

Vampire commented Mar 14, 2026

Hoping this is a Spring regression, I opened spring-projects/spring-framework#36463

@testlens-app

This comment has been minimized.

@testlens-app

This comment has been minimized.

Copy link
Copy Markdown
Member Author

Vampire commented Mar 21, 2026

Turns out it was not a Spring regression, but it switched from using debug information to get parameter names for bean names to using the -parameter metadata and Groovy also does not write that by default.

Now the test should become green.

@Vampire Vampire requested a review from AndreasTu March 21, 2026 12:07
Copy link
Copy Markdown
Member Author

Vampire commented Mar 21, 2026

Indeed this would have stopped working with Spring 6.1 already, but we still test against 6.0.0

@testlens-app

This comment has been minimized.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
spock-spring/spring7-test/src/test/groovy/org/spockframework/spring7/NoMockConfig.groovy (1)

32-34: Add timeout to unbounded .get() call in ServiceExecutor.exec().

Line 33 calls .get() without a timeout, which can block indefinitely if the executor is miswired or stalled. Use a bounded wait with an explicit timeout duration.

Suggested refactor
+import java.util.concurrent.TimeUnit
 import java.util.concurrent.Callable
 import java.util.concurrent.ExecutorService
@@
-  def exec() {
-    executorService.submit({"done"} as Callable).get()
+  String exec() {
+    executorService.submit({ "done" } as Callable<String>).get(5, TimeUnit.SECONDS)
   }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@spock-spring/spring7-test/src/test/groovy/org/spockframework/spring7/NoMockConfig.groovy`
around lines 32 - 34, The exec() method currently calls Future.get() with no
timeout (executorService.submit({"done"} as Callable).get()), which can block
indefinitely; change this to use Future.get(long, TimeUnit) with a reasonable
bounded timeout (e.g. 5 seconds) and handle TimeoutException,
InterruptedException and ExecutionException appropriately (log/propagate/fail
the test). Update ServiceExecutor.exec()/NoMockConfig.exec() to call
get(<timeout>, TimeUnit.SECONDS), add the TimeUnit import, and ensure you catch
TimeoutException to cancel the Future and surface a clear error.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In
`@spock-spring/spring7-test/src/test/groovy/org/spockframework/spring7/NoMockConfig.groovy`:
- Around line 32-34: The exec() method currently calls Future.get() with no
timeout (executorService.submit({"done"} as Callable).get()), which can block
indefinitely; change this to use Future.get(long, TimeUnit) with a reasonable
bounded timeout (e.g. 5 seconds) and handle TimeoutException,
InterruptedException and ExecutionException appropriately (log/propagate/fail
the test). Update ServiceExecutor.exec()/NoMockConfig.exec() to call
get(<timeout>, TimeUnit.SECONDS), add the TimeUnit import, and ensure you catch
TimeoutException to cancel the Future and surface a clear error.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 8008ceac-0658-4400-a163-13a66722ebf4

📥 Commits

Reviewing files that changed from the base of the PR and between 44cffd5 and 98d51a0.

📒 Files selected for processing (19)
  • settings.gradle
  • spock-spring/spring.gradle
  • spock-spring/spring3-test/spring3-test.gradle
  • spock-spring/spring5-test/spring5-test.gradle
  • spock-spring/spring6-test/spring6-test.gradle
  • spock-spring/spring7-test/spring7-test.gradle
  • spock-spring/spring7-test/src/test/groovy/org/spockframework/spring7/NoMockConfig.groovy
  • spock-spring/spring7-test/src/test/groovy/org/spockframework/spring7/RuntimeCompatibilitySpec.groovy
  • spock-spring/spring7-test/src/test/groovy/org/spockframework/spring7/SpringBeanTest.groovy
  • spock-spring/spring7-test/src/test/groovy/org/spockframework/spring7/SpringRunnerTest.java
  • spock-spring/spring7-test/src/test/groovy/org/spockframework/spring7/TestConfig.groovy
  • spock-spring/src/main/java/org/spockframework/spring/SpringExtension.java
  • spock-spring/src/test/groovy/org/spockframework/spring/ContextHierarchyExample.groovy
  • spock-spring/src/test/groovy/org/spockframework/spring/InjectionExamples.groovy
  • spock-spring/src/test/groovy/org/spockframework/spring/MockInjectionExample.groovy
  • spock-spring/src/test/groovy/org/spockframework/spring/SharedFieldsInjection.groovy
  • spock-spring/src/test/groovy/org/spockframework/spring/docs/MockExamples.groovy
  • spock-spring/src/test/groovy/org/spockframework/spring/mock/ComplexUsageSpec.groovy
  • spock-spring/src/test/groovy/org/spockframework/spring/mock/imported/SpringSpyWithAopProxyTests.groovy
💤 Files with no reviewable changes (1)
  • spock-spring/src/test/groovy/org/spockframework/spring/mock/ComplexUsageSpec.groovy
✅ Files skipped from review due to trivial changes (4)
  • spock-spring/spring3-test/spring3-test.gradle
  • spock-spring/spring7-test/src/test/groovy/org/spockframework/spring7/TestConfig.groovy
  • spock-spring/spring7-test/src/test/groovy/org/spockframework/spring7/RuntimeCompatibilitySpec.groovy
  • spock-spring/spring5-test/spring5-test.gradle
🚧 Files skipped from review as they are similar to previous changes (6)
  • spock-spring/spring6-test/spring6-test.gradle
  • settings.gradle
  • spock-spring/spring7-test/src/test/groovy/org/spockframework/spring7/SpringRunnerTest.java
  • spock-spring/spring7-test/src/test/groovy/org/spockframework/spring7/SpringBeanTest.groovy
  • spock-spring/spring7-test/spring7-test.gradle
  • spock-spring/spring.gradle

@testlens-app
Copy link
Copy Markdown

testlens-app bot commented Mar 21, 2026

🔎 No tests executed 🔎

🏷️ Commit: 75ddaa1
▶️ Tests: 0 executed
⚪️ Checks: 61/61 completed


Learn more about TestLens at testlens.app.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (2)
spock-spring/src/test/groovy/org/spockframework/spring/docs/MockExamples.groovy (1)

30-50: Prefer isolated qualifier examples instead of dual-annotating each field.

Adding both @JavaxNamed and @jakarta.inject.Named to the same injection point makes failures harder to attribute and weakens the example’s explanatory value. Consider separate examples/tests per qualifier flavor.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@spock-spring/src/test/groovy/org/spockframework/spring/docs/MockExamples.groovy`
around lines 30 - 50, The fields GreeterService serviceMock, serviceStub,
serviceSpy and alternativeMock are dual-annotated with `@JavaxNamed` and
`@Autowired` `@Named` which confuses failures; split the examples so each injection
point shows only one qualifier flavor: either use `@JavaxNamed` on its own for a
dedicated test/example (e.g. serviceMock/serviceStub/serviceSpy with
`@JavaxNamed`) and create separate examples/tests that use `@Autowired` `@Named` (or
jakarta variant) for the same logical cases, removing the dual annotations from
each field and keeping one qualifier per example to make failures and intent
clear.
spock-spring/src/test/groovy/org/spockframework/spring/SharedFieldsInjection.groovy (1)

60-63: Separate javax/jakarta injection scenarios to avoid masked regressions.

Using both @javax.inject.Inject and @jakarta.inject.Inject on the same field makes the test pass even if one path breaks. Consider parameterizing these specs so each run uses exactly one annotation variant.

Also applies to: 85-88, 116-119, 206-209

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@spock-spring/src/test/groovy/org/spockframework/spring/SharedFieldsInjection.groovy`
around lines 60 - 63, The test uses both javax and jakarta injection annotations
on the same field (e.g., the SharedFieldsInjection.groovy fields like
sharedService annotated with `@javax.inject.Inject` and `@Inject`), which masks
regressions; update the spec to run separate scenarios for each injection API by
parameterizing the tests (or duplicating the field cases) so each execution uses
exactly one annotation variant per field (apply same change for the other
occurrences around lines with the other shared fields referenced in the review);
ensure the parameterization/variants exercise only `@javax.inject.Inject` in one
run and only `@jakarta.inject.Inject` in the other so failures aren’t hidden.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In
`@spock-spring/src/test/groovy/org/spockframework/spring/docs/MockExamples.groovy`:
- Around line 30-50: The fields GreeterService serviceMock, serviceStub,
serviceSpy and alternativeMock are dual-annotated with `@JavaxNamed` and
`@Autowired` `@Named` which confuses failures; split the examples so each injection
point shows only one qualifier flavor: either use `@JavaxNamed` on its own for a
dedicated test/example (e.g. serviceMock/serviceStub/serviceSpy with
`@JavaxNamed`) and create separate examples/tests that use `@Autowired` `@Named` (or
jakarta variant) for the same logical cases, removing the dual annotations from
each field and keeping one qualifier per example to make failures and intent
clear.

In
`@spock-spring/src/test/groovy/org/spockframework/spring/SharedFieldsInjection.groovy`:
- Around line 60-63: The test uses both javax and jakarta injection annotations
on the same field (e.g., the SharedFieldsInjection.groovy fields like
sharedService annotated with `@javax.inject.Inject` and `@Inject`), which masks
regressions; update the spec to run separate scenarios for each injection API by
parameterizing the tests (or duplicating the field cases) so each execution uses
exactly one annotation variant per field (apply same change for the other
occurrences around lines with the other shared fields referenced in the review);
ensure the parameterization/variants exercise only `@javax.inject.Inject` in one
run and only `@jakarta.inject.Inject` in the other so failures aren’t hidden.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 2660bd22-0a50-438d-8c92-14388bb561cb

📥 Commits

Reviewing files that changed from the base of the PR and between 98d51a0 and 75ddaa1.

📒 Files selected for processing (19)
  • settings.gradle
  • spock-spring/spring.gradle
  • spock-spring/spring3-test/spring3-test.gradle
  • spock-spring/spring5-test/spring5-test.gradle
  • spock-spring/spring6-test/spring6-test.gradle
  • spock-spring/spring7-test/spring7-test.gradle
  • spock-spring/spring7-test/src/test/groovy/org/spockframework/spring7/NoMockConfig.groovy
  • spock-spring/spring7-test/src/test/groovy/org/spockframework/spring7/RuntimeCompatibilitySpec.groovy
  • spock-spring/spring7-test/src/test/groovy/org/spockframework/spring7/SpringBeanTest.groovy
  • spock-spring/spring7-test/src/test/groovy/org/spockframework/spring7/SpringRunnerTest.java
  • spock-spring/spring7-test/src/test/groovy/org/spockframework/spring7/TestConfig.groovy
  • spock-spring/src/main/java/org/spockframework/spring/SpringExtension.java
  • spock-spring/src/test/groovy/org/spockframework/spring/ContextHierarchyExample.groovy
  • spock-spring/src/test/groovy/org/spockframework/spring/InjectionExamples.groovy
  • spock-spring/src/test/groovy/org/spockframework/spring/MockInjectionExample.groovy
  • spock-spring/src/test/groovy/org/spockframework/spring/SharedFieldsInjection.groovy
  • spock-spring/src/test/groovy/org/spockframework/spring/docs/MockExamples.groovy
  • spock-spring/src/test/groovy/org/spockframework/spring/mock/ComplexUsageSpec.groovy
  • spock-spring/src/test/groovy/org/spockframework/spring/mock/imported/SpringSpyWithAopProxyTests.groovy
💤 Files with no reviewable changes (1)
  • spock-spring/src/test/groovy/org/spockframework/spring/mock/ComplexUsageSpec.groovy
✅ Files skipped from review due to trivial changes (5)
  • spock-spring/spring3-test/spring3-test.gradle
  • settings.gradle
  • spock-spring/spring5-test/spring5-test.gradle
  • spock-spring/spring6-test/spring6-test.gradle
  • spock-spring/spring7-test/src/test/groovy/org/spockframework/spring7/TestConfig.groovy
🚧 Files skipped from review as they are similar to previous changes (11)
  • spock-spring/src/main/java/org/spockframework/spring/SpringExtension.java
  • spock-spring/src/test/groovy/org/spockframework/spring/ContextHierarchyExample.groovy
  • spock-spring/src/test/groovy/org/spockframework/spring/mock/imported/SpringSpyWithAopProxyTests.groovy
  • spock-spring/src/test/groovy/org/spockframework/spring/MockInjectionExample.groovy
  • spock-spring/spring7-test/src/test/groovy/org/spockframework/spring7/SpringRunnerTest.java
  • spock-spring/spring7-test/src/test/groovy/org/spockframework/spring7/SpringBeanTest.groovy
  • spock-spring/spring7-test/src/test/groovy/org/spockframework/spring7/RuntimeCompatibilitySpec.groovy
  • spock-spring/spring.gradle
  • spock-spring/spring7-test/src/test/groovy/org/spockframework/spring7/NoMockConfig.groovy
  • spock-spring/spring7-test/spring7-test.gradle
  • spock-spring/src/test/groovy/org/spockframework/spring/InjectionExamples.groovy

Copy link
Copy Markdown
Member Author

Vampire commented Mar 28, 2026

Merge activity

  • Mar 28, 1:35 PM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Mar 28, 1:35 PM UTC: @Vampire merged this pull request with Graphite.

@Vampire Vampire merged commit b71e3d7 into master Mar 28, 2026
64 of 66 checks passed
@Vampire Vampire deleted the spring7-test branch March 28, 2026 13:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants