Add junit-jupiter when only junit.framework.TestCase is used - #1117
Open
manduinca wants to merge 1 commit into
Open
Add junit-jupiter when only junit.framework.TestCase is used#1117manduinca wants to merge 1 commit into
manduinca wants to merge 1 commit into
Conversation
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?
AddJupiterDependenciesnow also scans for uses ofjunit.framework..*, next toorg.junit..*, when deciding whether to addjunit-jupiter. The two scanners share the accumulator, so either one marks the project as using JUnit and the scope logic is unchanged.What's your motivation?
Fixes #1113. In a project whose tests only extend
junit.framework.TestCase,JUnit4to5Migrationremovedjunit:junitbut never added Jupiter, because the scanner runs on the sources beforeMigrateJUnitTestCaserewrites them and noorg.junittype is in use at that point. The migrated project didn't compile.Anything in particular you'd like reviewers to focus on?
Whether broadening the guard here is the shape you want, versus making the
RemoveDependencyin the composite conditional. This one keepsAddJupiterDependenciescorrect on its own, which also covers running it standalone on a JUnit 3 codebase.Have you considered any alternatives or workarounds?
A single glob covering both packages doesn't exist (
org.junitandjunit.frameworkshare no prefix), andAddDependencytakes oneonlyIfUsingpattern, hence the two scanners.Any additional context
Three tests: one on
AddJupiterDependencieswith aTestCasesubclass in the test source set, a negative one with no JUnit at all (nothing is added), and one on theJUnit4to5Migrationcomposite reproducing the issue (pom withjunit:junitonly), assertingjunit-jupiteris added andjunitremoved. The two positive ones fail onmainand pass with the change.On building locally: since #1116 the build plugins resolve from the Code Genome repository, which asks for credentials I don't have, and
latest.release(2.23.4) depends on rewrite 8.91.4, which isn't on Maven Central. With the plugins pinned to 2.23.1 locally (not part of this PR)./gradlew buildpasses: 1859 tests, 0 failures,recipes.csvvalidated.Checklist
./gradlew buildlocally, and committed any resulting changes torecipes.csv(with the plugin pin described above;recipes.csvunchanged)