Repository navigation
MigrateAssertionFailedError: leave source files using junit.framework.TestResult untouched - #1175
Open
mohitduhan19 wants to merge 3 commits 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?
MigrateAssertionFailedErrornow has aDoesNotUseTypeprecondition (withincludeImplicit: true) onjunit.framework.TestResult, so source files that use it are left untouched.What's your motivation?
Follow-up to #1114 (the secondary
MigrateAssertionFailedErrorpoint), as discussed in #1168.TestResult.addFailure(Test, junit.framework.AssertionFailedError)only accepts the JUnit 3 type. Today the recipe retargetsjunit.framework.AssertionFailedErrortoorg.opentest4j.AssertionFailedErroreverywhere in the file, including the cast passed intoaddFailure(..), so the argument type no longer matches and the file stops compiling. A class that reports to aTestResultis participating in the JUnit 3 execution model, consistent with #1168 which now leaves suchTestCasesubclasses untouched inMigrateJUnitTestCase.Anything in particular you'd like reviewers to focus on?
The guard is per source file, matching #1168.
includeImplicit: truealso covers files that only reachTestResultthrough a method return type (e.g.createResult().addFailure(..)) without importing it.Have you considered any alternatives or workarounds?
Only skipping the
AssertionFailedErrorreferences that flow intoaddFailure(..). That would leave a mix of both exception types in one file, so skipping the whole file seemed simpler and safer.Any additional context
Tests added:
MigrateAssertionFailedErrorTest: a positive case (still migrated), the reproduction from MigrateJUnitTestCase rewrites super.run(TestResult) to Assertions.run(...), which does not exist #1114, and an implicit-onlyTestResultuse; both negative cases fail without the change.JUnit5MigrationTest#leaveTestCaseReportingToTestResultUntouched: the MigrateJUnitTestCase rewrites super.run(TestResult) to Assertions.run(...), which does not exist #1114 reproduction under the fullJUnit4to5Migration, which now leaves the file untouched (together with MigrateJUnitTestCase: leave TestCase subclasses overriding run(TestResult) untouched #1168).Checklist
./gradlew buildlocally, and committed any resulting changes torecipes.csv(no recipe names, descriptions or options changed, sorecipes.csvshould be unaffected; I ran thejunit5package tests locally and they pass, apart from the Gradle Tooling API tests that couldn't run in my environment)