Replies: 1 comment 1 reply
-
Have a look at https://spockframework.org/spock/docs/2.4-M5/extensions.html#interceptors your extension will need to use another interceptor point if you want to run after Spring. This isn't a bug, you extension probably only worked because of some wrong behavior of Spock that has been fixed. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Describe the bug
Upgrading Spock 2.4-M1-groovy-4.0 to any version between 2.4-M2-groovy-4.0 and to 2.4-M5-groovy-4.0
We use a Spock extension to run specs within a certain (thread-local) context.
The Spock specs or features are annotated with an annotation
@WithTenantContext
. The annotation is handled by theTenantContextExtension
.The test application contains an initializing bean, verifying that the tenant context is not set during Spock initialization.
In the example code below, the assert
assert TenantContextHolder.currentTenant == null
succeeds during all Spock versions up to2.4-M1-groovy-4.0
, but fails since2.4-M2-groovy-4.0
and newer.To Reproduce
Spec:
Test application:
Annotation:
Extension:
The
TenantContextProvider
is implemented with code similar towhere
TenantContextHolder
is a thread-local storage of some context.Expected behavior
The spec to succeed, no thread local context should be set during the setup of the spec (by the Spring extension).
Actual behavior
The assertion fails, because a thread-local context is set during spec initialization.
Java version
Java 11, or 17 or 21
Buildtool version
Gradle 8.5 until Gradle 8.13
What operating system are you using
Linux
Dependencies
Below is the dependency diagram for the
2.4-M2-groovy-4.0
version. Newer dependency versions (also of other unrelated dependencies) shows the same behaviour as described in this issue.Additional context
No response
Beta Was this translation helpful? Give feedback.
All reactions