Skip to content

MockitoExtension fails cleanup when aborted before setup #3622

@AndreKurait

Description

@AndreKurait

In Junit, extensions can throw org.opentest4j.TestAbortedException which will abort any subsequent setup steps while afterEach will still run.

When MockitoExtension is declared after a beforeEach extension that skips, mockito's beforeEach will not be executed but it's afterEach will causing an exception:

java.lang.NullPointerException: Cannot invoke "java.util.Set.forEach(java.util.function.Consumer)" because the return value of "org.junit.jupiter.api.extension.ExtensionContext$Store.remove(Object, java.lang.Class)" is null

	at org.mockito.junit.jupiter.MockitoExtension.afterEach(MockitoExtension.java:194)
...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions