Skip to content

Conversation

alsin
Copy link

@alsin alsin commented Oct 16, 2025

Motivation:

If a @Test method fails then potential VertxTestContext injected into a @AfterEach method (if any, of course) is not awaited.
For instance, a test might want to perform test data cleanup in a series of asynchronous operations in such a @AfterEach method and VertxTestContext could be used to gracefully wait for their end of operation. Unfortunately, as of now, if a test fails it does not wait for the test context injected into an after test method.

Conformance:

You should have signed the Eclipse Contributor Agreement as explained in https://github.com/eclipse/vert.x/blob/master/CONTRIBUTING.md
Please also make sure you adhere to the code style guidelines: https://github.com/vert-x3/wiki/wiki/Vert.x-code-style-guidelines

Copy link
Contributor

@tsegismont tsegismont left a comment

Choose a reason for hiding this comment

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

Thanks for this PR @alsin

Please see comments inline. When updating the PR, please sign-off your commits (using the email that is registered at the Eclipse Fdn for your contributor agreement).

Comment on lines +183 to +190
final boolean isNotInAfterEachMethod = Optional.ofNullable(invocationContext)
.map(ReflectiveInvocationContext::getExecutable)
.map(executable -> executable.getAnnotation(AfterEach.class))
.isEmpty();

if (isNotInAfterEachMethod) {
return;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This might fix the problem for @AfterEach methods, but not for @AfterAll ones.

The extension creates a new VertxTestContext for each intercepted method. I think the criterion for waiting the completion of the context should be that the execution exception hasn't changed during the invocation

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.

3 participants