Repository navigation
Only turn the WireMockRule field's @Rule into @RegisterExtension in UseWiremockExtension - #1218
Merged
Merged
Conversation
…` in `UseWiremockExtension` `UseWiremockExtension` queued a file-wide `ChangeType` from `org.junit.Rule` to `RegisterExtension` as soon as it saw a `new WireMockRule(..)`, so every other rule in the class was retyped too. A `@Rule TemporaryFolder tmp` next to the WireMock rule became `@RegisterExtension TemporaryFolder tmp`, which Jupiter rejects at runtime, and `TemporaryFolderToTempDir` and `TestRuleToTestInfo` later in `JUnit4to5Migration` no longer recognised those fields. Now only the `@Rule` on a `WireMockRule` field is replaced.
23 of 76 tasks
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.
UseWiremockExtensionswappedorg.junit.RuleforRegisterExtensionacross the whole file once it saw anew WireMockRule(..), so other rules in the same class were retyped too:came out as
@RegisterExtension public TemporaryFolder tmp, which Jupiter rejects at runtime. WithinJUnit4to5Migrationthe recipe runs beforeTemporaryFolderToTempDirandTestRuleToTestInfo, so those then no longer recognised their fields. Now only the@Ruleon aWireMockRulefield becomes@RegisterExtension, andorg.junit.Ruleis only removed when nothing else uses it. ThroughJUnit4to5Migration, the folder now becomes@TempDir public File tmp.This overlaps with #1191, which adds a second file-wide
ChangeTypein the same spot, fororg.junit.ClassRule. That would hit the same problem for other class rules (e.g. a@ClassRule static TemporaryFolder). Once this is merged, #1191 could match@org.junit.ClassRulein the newvisitVariableDeclarationsalongside@Ruleinstead of queueing aChangeType. ItsclassRuleBecomesStaticRegisteredExtensiontest should pass unchanged.Fixes item B1 of #1211.