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

Bean Overrides like @MockitoBean and @TestBean should not be allowed on static fields #33922

Closed
sbrannen opened this issue Nov 20, 2024 · 0 comments
Assignees
Labels
in: test Issues in the test module type: bug A general bug
Milestone

Comments

@sbrannen
Copy link
Member

It's currently possible to declare a bean override field as static.

For example, the following currently works in a test class.

@MockitoBean
static ExampleService service;

However, support for static fields was unintentional and does not align with @Autowired semantics where the annotated field cannot be static.

In light of that, we should reject static bean override fields.

@sbrannen sbrannen added in: test Issues in the test module type: bug A general bug labels Nov 20, 2024
@sbrannen sbrannen added this to the 6.2.1 milestone Nov 20, 2024
@sbrannen sbrannen self-assigned this Nov 20, 2024
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: bug A general bug
Projects
None yet
Development

No branches or pull requests

1 participant