Skip to content

Issue 3054 avoiding inclusion of the suppressed PreconditionViolation… #4439

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

BassemElMasry
Copy link
Contributor

@BassemElMasry BassemElMasry commented Mar 31, 2025

…Exception in the stacktrace

Overview

This PR is aimed to resolve the issue described here Issue 3054

Shall we include a test under ParameterizedTestIntegrationTests to ensure that suppressed exceptions are not included? I have tried but could not replicate the exact issue mentioned for static initializer so maybe we can take another approach like violating a specific PreCondition and ensure that the default one under the stream.close is not included in the suppressed exceptions.

I hereby agree to the terms of the JUnit Contributor License Agreement.


Definition of Done

@marcphilipp
Copy link
Member

Shall we include a test under ParameterizedTestIntegrationTests to ensure that suppressed exceptions are not included? I have tried but could not replicate the exact issue mentioned for static initializer so maybe we can take another approach like violating a specific PreCondition and ensure that the default one under the stream.close is not included in the suppressed exceptions.

I've added a test in cb3d5d6.

try {
stream.close();
}
catch (Throwable t2) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should generally discard all Throwables thrown from providers' onClose callbacks. The exception could contain an important hint so adding it as a suppressed exception could be useful. Therefore, I think we should introduce a custom TemplateInvocationValidationException (in org.junit.jupiter.api.extension) that extends JUnitException and throw it from here:

Preconditions.condition(invocationCount.get() > 0 || declarationContext.isAllowingZeroInvocations(),
() -> String.format("Configuration error: You must configure at least one set of arguments for this @%s", declarationContext.getAnnotationName())));

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@BassemElMasry Do you have time to make the change or should I take it from here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @marcphilipp , I can finalize it this week. Sorry I did not see the comments earlier. If this is not feasible for you, feel free to finalize it of course.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No worries! Finalizing it this week is fine, please go ahead! 🙂

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @marcphilipp unfortunately I had another medical emergency and just came out of the hospital yesterday. Can you please take care of this as I am very sick? 😭 I am so sorry for the delay I caused.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Parameterized tests: misleading error if exception was thrown in static initializer
2 participants