Skip to content

Conditional extension registration via @ExtendWith #1242

Closed
@Lubetkin

Description

@Lubetkin

I have a use case where I have a custom annotation i.e. @MyAnnotation that is annotated by @ExtendWith(Extension.class).

On a test method, I declare @MyAnnotation and another annotation, @OtherAnnotation.

@MyAnnotation
@OtherAnnotation
void test(){...}

I want to be able to deactivate the extension registered in MyAnnotation (Extension.class) when the second annotation, OtherAnnotation is present, because JUnit Jupiter takes the extension from MyAnnotation and runs it, but I want that MyAnnotation could be used as a self contained annotation in other test cases.

Is there a way to tell if OtherAnnotation is present and not run the Extension.class in MyAnnotation?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions