Skip to content

@ExtendWith cannot be used as a repeatable annotation directly on fields and parameters #4059

@sbrannen

Description

@sbrannen

Overview

When I introduced support for declarative extension registration on fields and parameters in JUnit Jupiter 5.8, I neglected to sync the @Target declaration for @Extensions with the new supported targets for @ExtendWith.

Consequently, it is possible to declare a single @ExtendWith annotation on a field or parameter, but it is not currently possible to declare multiple @ExtendWith annotations directly on a field or parameter.

For example, the following currently fails to compile.

@ExtendWith(RandomNumberExtension.class)
@ExtendWith(NumberParameterResolver.class)
private int magicNumber;

Similarly, the following also fails to compile.

@BeforeEach
void prepareTestData(
		@ExtendWith(RandomNumberExtension.class)
		@ExtendWith(NumberParameterResolver.class)
		int magicNumber
	) {

	// method body...
}

Related Issues

Deliverables

  • Ensure @ExtendWith can be used as a repeatable annotation directly on fields and parameters
  • Remove exclusion in ArchUnitTests
  • Backport to 5.11.x branch

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions