Skip to content

Exception in close of ExtensionContext.Store.CloseableResource swallows exception from test #2582

@markus-popp

Description

@markus-popp

I have a custom written extension with a CloseableResource in the ExtensionContext. When the resource throws an exception while attempting to close it, exceptions thrown in the test are swallowed. In my specific case there is too little information in the exception thrown in the close-method because it could be a follow-up problem from the exception thrown in the test. Therefore i need to see both exceptions in the test-result.

Steps to reproduce

@ExtendWith(MyExtension.class)
class TestExceptionInExtension {

    @Test
    void test() {
        throw new RuntimeException("Exception in Test.");
    }
}

class MyExtension implements BeforeEachCallback {

    private static final ExtensionContext.Namespace NAMESPACE = ExtensionContext.Namespace.create(MyExtension.class);

    @Override
    public void beforeEach(ExtensionContext context) {
        context.getStore(NAMESPACE).put("myResource", (ExtensionContext.Store.CloseableResource) () -> {
            throw new RuntimeException("Exception in Extension.");
        });
    }
}

Context

  • Used versions (Jupiter): 5.8.0-M1
  • Build Tool/IDE: IntelliJ IDEA 2020.3.2

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions