Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

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

Closed
3 tasks done
sbrannen opened this issue Oct 8, 2024 · 0 comments · Fixed by #4082
Closed
3 tasks done

Comments

@sbrannen
Copy link
Member

sbrannen commented Oct 8, 2024

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
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants