Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove throws from method that adopts assertThrows #564

Merged
merged 4 commits into from
Aug 8, 2024

Conversation

timtebeek
Copy link
Contributor

@timtebeek timtebeek commented Aug 8, 2024

@timtebeek timtebeek added the enhancement New feature or request label Aug 8, 2024
@timtebeek
Copy link
Contributor 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
1 of 2 checks passed
@timtebeek timtebeek deleted the remove-throws-from-method-with-assertThrows branch August 8, 2024 11:33
@shivanisky
Copy link
Contributor

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