Repository navigation
Only migrate the two-argument InvocationInterceptor.interceptDynamicTest in RemoveInterceptDynamicTest - #1221
Merged
Conversation
…Test` in `RemoveInterceptDynamicTest` The recipe matched `interceptDynamicTest(..)`, so it also deleted overrides of the three-argument `interceptDynamicTest(Invocation, DynamicTestInvocationContext, ExtensionContext)` that JUnit 6 still has, silently dropping user interceptor logic. It now only matches the removed two-argument signature, and rather than deleting that override it adds a `DynamicTestInvocationContext` parameter so the body keeps running under JUnit 6, as it did through the JUnit 5 default delegation. The two-argument override is still removed when the class already overrides the three-argument one, or for non-Java sources.
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.
RemoveInterceptDynamicTestmatchedinterceptDynamicTest(..), so it also deleted overrides of the three-argumentinterceptDynamicTest(Invocation, DynamicTestInvocationContext, ExtensionContext), which JUnit 6 still has (checked againstjunit-jupiter-api6.1.3 inclasspath.tsv.gz). User interceptors lost their logic without any warning. Deleting the removed two-argument override also threw away its body, even though under JUnit 5 the default three-argument method delegated to it.The recipe now only matches the two-argument signature. Instead of deleting it, it adds a
DynamicTestInvocationContextparameter in the middle (with a fresh name ifinvocationContextis taken) and keeps the body:When the class already overrides the three-argument method, or the source isn't Java (for example Kotlin), the two-argument override is still removed, same as before. The display name and description are updated to match. The existing test no longer uses a stub
Methodclass: the no-change test importsjava.lang.reflect.Methodfrom the real JDK.Verified with
./gradlew test --tests 'org.openrewrite.java.testing.junit6.*'(90 tests, 0 failures). All 4RemoveInterceptDynamicTestTestcases fail against the recipe onmain.Fixes item C11 of #1211.