-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Introduce UnrecoverableThrowable abstraction for exception that should terminate test plan #3037
Comments
I think a more flexible option would be to introduce a configuration parameter for configuring a comma-separated list of fully-qualified class or interface names for such exceptions. WDYT? |
Like this https://junit.org/junit5/docs/current/user-guide/#running-tests-config-params? Never had a chance to need them but I think that'll be ok.
Assuming I can put |
Perhaps, we want to support both at the same time? Having an 🤔 ... if there was a |
I don't think that would work. IIRC, JUnit only looks for a single I think we might have an open (or closed due to inactivity) issue related to specifying a different location for the file or potentially supporting multiple files. If we don't introduce support for multiple files, a feature like this would have to addressed differently -- perhaps via the |
Thinking more about multiple files, they may cause more problems than they solve. Considering that there are preferences like |
Might the original use case not be better supported by #2816? |
@mpkorstanje, unless I'm missing something about that feature, I don't see how. In this case, I want to stop the test plan because something went wrong during initialization. Not sure how an option to load closable resources into the context would help with that. And if it's about starting/stopping containers, then I'd guess it could be done using that closable resource abstraction (except it's not there yet), but if that resource wouldn't load, I'd still need a way to stop the test plan somehow. |
Your need to stop the test plan with an exception is a solution to a more general need to be able to create a resource prior to the execution of the test plan. Using a listener may not be the right abstraction.
It's my assumption that the test plan would fail before it got executed if the resources could not be created. |
Only one error terminates the test plan:
OutOfMemoryError
. Sometimes it might be beneficial to have more control over this. In my case, I'm bringing up test containers before the test suite starts. I implemented this usingTestExecutionListener
. I start containers intestPlanExecutionStarted
and stop them intestPlanExecutionFinished
. It happens from time to time that a container does not start. In this case, I want to terminate the test plan because it does not make sense to run any tests when some required container is down.It'd be good to introduce a class or, better, an interface like
UnrecoverableThrowable
and check if throwable is an instance ofOutOfMemory || UnrecoverableThrowable
. Then users could create custom exceptions that implement said interface and terminate the test plan.If this idea sounds, I can create a PR.
The text was updated successfully, but these errors were encountered: