-
Notifications
You must be signed in to change notification settings - Fork 8.7k
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
optimize: Changed exception check by JUnit API usage #3589
Conversation
Signed-off-by: Elvys Soares <eas5@cin.ufpe.br>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
plz modify the title of the issue to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Codecov Report
@@ Coverage Diff @@
## develop #3589 +/- ##
=============================================
- Coverage 52.08% 52.07% -0.01%
- Complexity 3499 3500 +1
=============================================
Files 638 638
Lines 21108 21108
Branches 2618 2617 -1
=============================================
- Hits 10995 10993 -2
- Misses 9027 9028 +1
- Partials 1086 1087 +1
|
Problem:
The Exception Handling test smell occurs when the test outcome is manually determined through pass or fail method calls, dependent on the production method throwing an exception, generally inside a try/catch block. This refactoring proposal aims to make the exception catching a responsibility of the test framework, which is already provided by its API. Also, without using try/catch blocks, tests can be more straightforward and possibly more comprehensible and maintainable.
Solution:
We propose using JUnit's exception handling to automatically pass/fail the test instead of writing custom exception handling code. In this particular case, we added the possibly throwable object to the test method signature and removed the redundant
fail
method call and message.Result:
Before:
After: