Skip to content

Remove throws from method that adopts assertThrows#564

Merged
timtebeek merged 4 commits intomainfrom
remove-throws-from-method-with-assertThrows
Aug 8, 2024
Merged

Remove throws from method that adopts assertThrows#564
timtebeek merged 4 commits intomainfrom
remove-throws-from-method-with-assertThrows

Conversation

@timtebeek
Copy link
Copy Markdown
Member

@timtebeek timtebeek commented Aug 8, 2024

@timtebeek timtebeek added the enhancement New feature or request label Aug 8, 2024
Comment thread src/main/java/org/openrewrite/java/testing/junit5/UpdateTestAnnotation.java Outdated
@timtebeek
Copy link
Copy Markdown
Member Author

Turns out we were overthinking this one; as we already replace the entire method body with assertThrows, there are then no exception left to be thrown that are not already caught.

@timtebeek timtebeek marked this pull request as ready for review August 8, 2024 11:19
@timtebeek timtebeek merged commit ebd24fe into main Aug 8, 2024
@timtebeek timtebeek deleted the remove-throws-from-method-with-assertThrows branch August 8, 2024 11:33
@shivanisky
Copy link
Copy Markdown
Collaborator

shivanisky commented Aug 8, 2024

I'm just thinking with the above, what if the method throws multiple checked exceptions, and assertThrows only catches one, even if it is wrapping the entire method body. I think in that case, the remaining checked exception are still valid, or still not? From my memory I remember only removing one checked exception from the method signature, and keeping one when doing the junit 4 to 5 migration, where there were multiple checked exceptions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

Removed unused checked exceptions, as discovered in JUnit 4 to 5 migration

3 participants