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

Introduce error handling mechanism for validation and discovery errors #242

Open
11 of 22 tasks
marcphilipp opened this issue May 6, 2016 · 31 comments
Open
11 of 22 tasks

Comments

@marcphilipp
Copy link
Member

marcphilipp commented May 6, 2016

Overview

Validation errors (e.g., for invalid @BeforeEach method declarations) should not abort the entire discovery phase. Instead the discovery phase should continue, with the error tracked and reported during the execution phase.

Areas of Applicability

Proposals

  1. Allow engines to track errors by creating a special type of TestDescriptor such as an AlwaysFailingTestDescriptor, DeadOnArrivalTestDescriptor, or ErrorReportingTestDescriptor.
    • Tracked errors for such a corresponding TestDescriptor could then be thrown as an exception during the execution phase instead of executing the corresponding container or test.
  2. Introduce a new property in TestDescriptor that signals an error that was encountered during the discovery phase.
  3. Pass a reporting object from the Launcher into each TestEngine to report errors.

Related Issues

Deliverables

@sbrannen
Copy link
Member

The same is true for invalid custom display names supplied by the user, as described in #743.

I will therefore update the description of this issue to reflect the broader scope.

@sbrannen sbrannen changed the title Revisit validation and exception handling in the JUnit 5 TestEngine Introduce exception handling mechanism for validation errors in JUnit Jupiter Mar 23, 2017
@sbrannen
Copy link
Member

FYI: I have introduced a minimum set of Deliverables.

@gaganis
Copy link
Contributor

gaganis commented Mar 23, 2017

I am thinking this reminds me the approach we took for vintage to handle multiple assertion errors using a MultipleFailuresError.

We could be possible that we could store all validation errors in a Throwable - using a MultipleFailuresError when there is more than one, that would be carried over to the execution phase and when this is nonEmpty we would throw the exception instead of executing the test.


It might also be worth considering for this mechanism to track all exceptions that occur while processing a single discovered test and throw it in the execution phase.

This way instead of the whole process stopping, we could still process the rest of the tests that encountered no problems and only fail on single tests.

PS While I was writing, this @sbrannen changed the title and description and now it sound more like what I am writing here! 😃

@sbrannen
Copy link
Member

@gaganis, thanks for sharing your ideas.

A few notes...

No need to use MultipleFailuresError.

We're on Java 8 and can use suppressed exceptions.

Plus, we already have a ThrowableCollector within the JUnit Jupiter engine that could potentially be used for this purpose as well.

@sbrannen sbrannen changed the title Introduce exception handling mechanism for validation errors in JUnit Jupiter Introduce exception handling mechanism for validation and discovery errors Apr 15, 2017
@sbrannen
Copy link
Member

The scope of this issue has been broadened in order to encompass the Platform as well.

@jlink
Copy link
Contributor

jlink commented Apr 15, 2017

Rather than using exceptions of any kind, having some kind of notification collector as a return or in/out parameter seems more flexible since any exception will stop an engine's discovery phase whereas many notifications are just warnings or pieces of information .

@sbrannen
Copy link
Member

Rather than using exceptions of any kind, having some kind of notification collector as a return or in/out parameter seems more flexible since any exception will stop an engine's discovery phase whereas many notifications are just warnings or pieces of information .

Good point!

I'll change the title of this issue accordingly.

@sbrannen sbrannen changed the title Introduce exception handling mechanism for validation and discovery errors Introduce error handling mechanism for validation and discovery errors Apr 15, 2017
@sbrannen
Copy link
Member

FYI: title and description have updated.

marcphilipp added a commit that referenced this issue Mar 16, 2025
Instead of aborting test discovery on the first problematic selector
resolution result, they are now converted to discovery issues with
`ERROR` severity and reported during execution.

Issue: #242
marcphilipp added a commit that referenced this issue Mar 17, 2025
Instead of aborting test discovery on the first problematic selector
resolution result, they are now converted to discovery issues with
`ERROR` severity and reported during execution.

Issue: #242
marcphilipp added a commit that referenced this issue Mar 17, 2025
Instead of aborting test discovery on the first problematic selector
resolution result, they are now converted to discovery issues with
`ERROR` severity and reported during execution.

Issue: #242
marcphilipp added a commit that referenced this issue Mar 17, 2025
Instead of aborting test discovery on the first problematic selector
resolution result, they are now converted to discovery issues with
`ERROR` severity and reported during execution.

Issue: #242
marcphilipp added a commit that referenced this issue Mar 17, 2025
The goal is to ease testing for discovery issues encountered by an
engine (see #242).
marcphilipp added a commit that referenced this issue Mar 18, 2025
The goal is to ease testing for discovery issues encountered by an
engine (see #242).
marcphilipp added a commit that referenced this issue Mar 18, 2025
The goal is to ease testing for discovery issues encountered by an
engine (see #242).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment