Skip to content
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

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

spring-issuemaster opened this issue Jan 7, 2015 · 2 comments


Copy link

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:

  • #21544 Relax explicit TestContextBootstrapper resolution
  • #17606 Throw exception if multiple meta-annotations are found by AnnotationUtils

Referenced from: commits e85e976


This comment has been minimized.

Copy link
Collaborator Author

commented Jan 7, 2015

Phil Webb commented

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


This comment has been minimized.

Copy link
Collaborator Author

commented Apr 26, 2015

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
None yet
2 participants
You can’t perform that action at this time.