Skip to content

Support primary beans with ApplicationContextAssert.getBean #14874

@joshiste

Description

@joshiste

When having multiple beans defined with one marked with @Primary I'd expect that ApplicationContextAssert#getBean(Class<T>) to return the primary bean (like it is for application contexts). Instead it throws following error:


java.lang.AssertionError: 
Expecting:
 <Started application [AnnotationConfigWebApplicationContext@5c909414 id = 'org.springframework.web.context.support.AnnotationConfigWebApplicationContext@5c909414', applicationName = '', beanDefinitionCount = 76]>
single bean of type:
 <de.codecentric.boot.admin.server.notify.Notifier>
but found:
 <["testNotifierPrimary", "testNotifier2"]>

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions