Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Issue 3054 avoiding inclusion of the suppressed PreconditionViolation… #4439

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())));

# for free to join this conversation on GitHub. Already have an account? # 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