Repository navigation
Match Mockito and JUnit code by type, and format only what changes - #1195
Merged
Merged
Conversation
Found by new rewriteRun checks in rewrite-test, which rerun each test with the changed code respelled (a static import for a qualified call and the reverse, fully qualified type names) and fail a recipe that auto-formats a whole class. Formatting only what changed: - AddMissingNested formats only the class header after adding @nested. - MockitoJUnitRunnerToExtension and MockitoJUnitRunnerSilentToExtension drop a whole-class format after JavaTemplate's addAnnotation. - UpdateMockWebServer formats only the @AfterEach method it changes. - ReplaceInitMockToOpenMock and MockitoWhenOnStaticToMockStatic drop their whole-class formats. MockitoUtils.separateAddedMembers keeps the blank line after an added field. Matching by type: - MockitoWhenOnStaticToMockStatic finds the mocked class of a statically imported or fully qualified static call, and imports it. - RemoveEmptyTests matches `@Test` in any spelling. - RemoveDoNothingForDefaultMocks accepts `Mockito.doNothing()`. - ThenThrowCheckedExceptionToRuntimeException handles a fully qualified exception class literal. Two expectations no longer expect an untouched empty body `{}` to become `{\n}`. Three tests are added.
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.
Found by new rewriteRun checks in rewrite-test, which rerun each test with the changed code respelled (a static import for a qualified call and the reverse, fully qualified type names) and fail a recipe that auto-formats a whole class.
Formatting only what changed:
Matching by type:
@Testin any spelling.Mockito.doNothing().Two expectations no longer expect an untouched empty body
{}to become{\n}. Three tests are added.