Repository navigation
MigrateJUnitTestCase: leave TestCase subclasses overriding run(TestResult) untouched - #1168
Merged
timtebeek merged 3 commits intoOct 5, 2026
Conversation
timtebeek
approved these changes
Oct 5, 2026
timtebeek
left a comment
Member
There was a problem hiding this comment.
Thanks a lot for picking this up! Neat bit about JUnit 3 that I didn't know about yet.
Contributor
Author
|
Thanks for the quick review and merge, @timtebeek! Happy to take a look at the |
Member
|
That'd be appreciated, thanks! |
Closed
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?
MigrateJUnitTestCasenow leaves a source file untouched when it declares a method overridingjunit.framework.TestCase#run(TestResult). This is done with aPreconditions.not(new DeclaresMethod<>(...))guard (matching overrides) alongside the existingUsesTypepreconditions.What's your motivation?
A
TestCasethat overridesrun(TestResult)is hooking into the JUnit 3 execution model, which has no Jupiter equivalent (noTestResult, norunhook). Today the recipe half-migrates such a class:extends TestCaseis dropped, and theTestCase→org.junit.Assert→Assertionstype changes turnsuper.run(result)intoAssertions.run(result), which does not exist, so the result no longer compiles. As suggested in the issue, skipping the class leaves code that still compiles and runs.Anything in particular you'd like reviewers to focus on?
The guard is per source file, since the
ChangeType/AssertToAssertionsvisitors this recipe schedules run on the whole compilation unit.migrateOtherTestCasesWhenOneOverridesRunshows that otherTestCasesubclasses in the same run are still migrated.Have you considered any alternatives or workarounds?
Only skipping the
super.run(..)rewrite. That would still leave a class that overrides a method it no longer inherits and has lost the behavior it relied on, so skipping the whole class seemed safer.Any additional context
The secondary
MigrateAssertionFailedErrorpoint from the issue is not addressed here, to keep this change focused.Checklist
MigrateJUnitTestCaseTest(16/16) and the rest of thejunit5package tests locally, all passing