Skip to content

Introduce missing tests for Bean Override features #33742

Closed
@sbrannen

Description

@sbrannen

Overview

Over the past few weeks it has become apparent that our test suite does not fully cover all features of the Bean Override support in the TestContext framework.

To remedy that, we should introduce tests to cover corner cases and features that are currently not tested. As a starting point, we can adopt several of the tests for @MockBean and @SpyBean from Spring Boot's test suite.

Features to Test

The following is a list of features we should make sure we test before Spring Framework 6.2 GA.

  • Combining SpringExtension and MockitoExtension on the same test class, including support for @Captor combined with @MockitoSpyBean.
  • @MockitoBean, @MockitoSpyBean, and @TestBean with @DirtiesContext "before method" modes.
  • @MockitoBean with JUnit 4 and SpringMethodRule.
  • @MockitoBean and @MockitoSpyBean with @ContextHierarchy.
  • @MockitoBean and @MockitoSpyBean with generics and parameterized types.
  • @MockitoBean replacement of a bean with @Async methods.
  • @MockitoBean replacement of a scoped proxy.
  • @MockitoBean replacement of a Spring AOP proxy.
  • @MockitoSpyBean with circular dependencies.
  • Spring AOP proxy that wraps a Mockito spy created via @MockitoSpyBean.
  • @MockitoSpyBean on a field with generics can be used to replace an existing bean with matching generics that's produced by a FactoryBean that's programmatically registered via an ImportBeanDefinitionRegistrar.
  • @⁠MockitoBean and @⁠MockitoSpyBean can select a single candidate bean to override when there are multiple candidates that match the required type: via an explicit bean name, @⁠Qualifier, or @⁠Primary on one of the candidate beans.
  • Mock reset support for beans within the ApplicationContext configured via MockReset.before() and MockReset.after().

Related Issues

Metadata

Metadata

Assignees

Labels

in: testIssues in the test moduletype: taskA general task

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions