Skip to content

Explicit failure if multiple @BootstrapWith annotations are used on the same test [SPR-12602] #17203

New issue

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

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

Already on GitHub? Sign in to your account

Closed
spring-projects-issues opened this issue Jan 7, 2015 · 2 comments
Assignees
Labels
in: test Issues in the test module type: enhancement A general enhancement
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

spring-projects-issues commented Jan 7, 2015

Phil Webb opened SPR-12602 and commented

BootstrapUtils.resolveTestContextBootstrapper currently finds the first @BootstrapWith annotation to create the bootstrapper. If the user has accidentally included more than one @BootstrapWith annotation (via meta-annotated annotations) it's seemingly arbitrary which is used.

It would be better to throw an explicit error.


Affects: 4.1 GA

Issue Links:

Referenced from: commits e85e976

@spring-projects-issues
Copy link
Collaborator Author

Phil Webb commented

See spring-projects/spring-boot#1956 (comment) for more background.

@spring-projects-issues
Copy link
Collaborator Author

Sam Brannen commented

Completed as described in GitHub commit e85e976:

Fail if multiple @BootstrapWith's are present

Prior to this commit it was possible for two @BootstrapWith annotations
to be 'present' on a test class -- for example, via competing custom
composed annotations. However, only one of the annotations will ever be
used to bootstrap the TestContext Framework. Thus, in such scenarios
one of the annotations will be silently ignored.

This commit introduces a check for such scenarios. BootstrapUtils'
resolveTestContextBootstrapper() method now throws an
IllegalStateException if more than one @BootstrapWith annotation is
'present' on a given test class.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: test Issues in the test module type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

2 participants