Repository navigation
ParameterizedRunnerToParameterized: migrate classes whose @Parameters method is inherited - #1139
Open
mohitduhan19 wants to merge 6 commits into
Open
mohitduhan19 wants to merge 6 commits into
mohitduhan19 wants to merge 6 commits into
Conversation
3 of 4 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.
What's changed?
ParameterizedRunnerToParameterizedonly migrated a@RunWith(Parameterized.class)class when its@Parametersfactory was declared in that same class. When the factory is inherited from a superclass, the recipe now finds it on the supertype and references it the way@MethodSourceaccepts for a method outside the test class, e.g.@MethodSource("com.example.ParamBase#data"). The factory'snameis carried over as@ParameterizedTest(name = ...). This works for both constructor and@Parameterfield injection.When the constructor passes its arguments on to the superclass constructor (
super(value)), a Jupiter parameterized test method can't supply them, so rather than half-migrate the class the recipe now leaves it as is and adds a search marker explaining why, as the issue suggests.What's your motivation?
ParameterizedRunnerToParameterizedsilently skips classes whose@Parametersmethod is inherited, leaving a partially migrated class that #1126Anything in particular you'd like reviewers to focus on?
JavaType.Annotationvalues), since the superclass is usually in another source file.nestedRunners, the insertedinit...call isn't attributed when the class extends a type that is only available as source.@Parametersannotation, since removing it could break other subclasses that aren't (or can't be) migrated.@RunWith(Parameterized.class)class declares no@Parametersmethod of its own, so existing migrations are unchanged.Have you considered any alternatives or workarounds?
The
super(...)case could be migrated fully with JUnit 5.13's@ParameterizedClassand constructor injection. That felt like a larger design choice, so I kept to the search marker here; happy to follow up if you'd like that direction.Any additional context
All three new tests fail on
main("Recipe was expected to make a change but made no changes") and pass with this change, along with the rest ofParameterizedRunnerToParameterizedTest,EnclosedToNestedTestandJunitMockitoUpgradeIntegrationTest. I couldn't run the full Gradle build in my environment, so CI will be the first full run.Checklist
./gradlew buildlocally, and committed any resulting changes torecipes.csv(no recipes or options were added)