Repository navigation
fix: inject @InjectWireMock fields without explicit SpringExtension - #213
Merged
tomasbjerre merged 1 commit intoOct 5, 2026
Merged
Conversation
@ConfigureWireMock and @EnableWireMock only meta-annotated @ExtendWith with WireMockSpringJunitExtension, which became a pure ParameterResolver in #204. Field injection, resets and the default WireMock client now run from a Spring TestExecutionListener, which only fires when SpringExtension is registered - previously an implicit side effect of SpringExtension.getApplicationContext() being called during field lookup. Test classes without @SpringBootTest, @SpringJUnitConfig or an explicit @ExtendWith(SpringExtension.class) got null @InjectWireMock fields. Meta-annotate both annotations with an additional @ExtendWith(SpringExtension.class); @ExtendWith is @repeatable so this stacks cleanly with whatever a test class already registers. Fixes #212 Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
@ConfigureWireMock/@EnableWireMockonly meta-annotated@ExtendWith(WireMockSpringJunitExtension.class), which feat: support test engines other than JUnit Jupiter #204 turned into a pureParameterResolver. Field injection, resets and the default WireMock client now run fromWireMockTestExecutionListener, which only fires when Spring'sSpringExtensionis registered — previously that happened implicitly as a side effect ofSpringExtension.getApplicationContext()being called during field lookup.@SpringBootTest,@SpringJUnitConfigor an explicit@ExtendWith(SpringExtension.class)therefore gotnull@InjectWireMockfields (4.4.0+ regression, fixes [Bug]: @InjectWireMockfields are no longer injected in tests withoutSpringExtension` #212).@ConfigureWireMock/@EnableWireMockwith@ExtendWith(SpringExtension.class).@ExtendWithis@Repeatable, so this stacks cleanly with whatever a test class already registers and doesn't affect the Cucumber/TestNG path added in feat: support test engines other than JUnit Jupiter #204 (those don't go through JUnit 5 meta-annotation extension discovery).Test plan
InjectWireMockWithoutExplicitSpringExtensionTest, reproducing the issue's exact repro case (only@ConfigureWireMock+@InjectWireMock, no@SpringBootTest/@SpringJUnitConfig/explicitSpringExtension)../gradlew testpasses in full with no regressions.🤖 Generated with Claude Code