-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Introduce exception handling support for lifecycle callback methods #1509
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
Conversation
|
Added exception handling for BeforeAll/AfterAll methods |
sbrannen
left a comment
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.
Please add tests for the new exception handling callbacks.
| for (Method method : this.beforeAllMethods) { | ||
| throwableCollector.execute( | ||
| () -> executableInvoker.invoke(method, testInstance, extensionContext, registry)); | ||
| for (Method method: this.beforeAllMethods) { |
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.
Please reintroduce the space between method and :.
|
The build is currently broken due to formatting issues.
|
|
But where to put the tests (TestExecutionExceptionHandlerTests or BeforeAndAfterEachTests or a new class) without blowing up an existing class or repeating too much code in a new class? |
|
I'd probably just introduce a set of test classes parallel to the existing As for adhering to the DRY principle, just do your best. We can always refactor later. The main objective for starters is just having tests in place. |
|
and yeah.... please don't "blow up" anything. 😉 |
|
Tests added |
|
Finally removed the formatting issues - these checks are really pedantic... |
|
@phoenix384 Were you not able to simply run |
|
@phoenix384, you really shouldn't try to tackle formatting issues one-by-one. Instead, as @jbduncan mentioned, you should simply execute Alternatively, you can set up the formatting in your IDE. This is all documented in the CONTRIBUTING documentation for JUnit 5. |
|
The last failure appears to have something to do with Jacoco: https://travis-ci.org/junit-team/junit5/jobs/413706488#L1467-L1486 Maybe that's just an intermittent issue on the CI server. Does |
| */ | ||
| void handleTestExecutionException(ExtensionContext context, Throwable throwable) throws Throwable; | ||
|
|
||
| default void handleExceptionInBeforeAllMethod(ExtensionContext context, Throwable throwable) throws Throwable { |
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.
Team Decision: Please rename all newly introduced methods to better align with the naming convention of the previously existing method, e.g. handleBeforeAllMethodExecutionException etc.
|
5.4 is released and this is still not merged. Is there a reason? |
|
Hi @phoenix384,
Yes, requested changes have not yet been made (e.g., #1509 (comment)), and the following tasks under "Definition of Done" have not been addressed.
Please rebase on Thanks! |
|
Closing in favor of #1868. |
Overview
PR for Issue #1454
Make it possible to also handle exceptions thrown by BeforeEach/AfterEach methods via the TestExecutionExceptionHandler.
The new handler methods are default methods to make them optional and to not break the FunctionalInterface.
This PR is a proposal to solve the issue. It's not complete. The Javadoc is not adjusted and the exception handling for the BeforeAll/AfterAll methods is missing.
I hereby agree to the terms of the JUnit Contributor License Agreement.
Definition of Done
@APIannotations