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 in @TestConfiguration is ignored [SPR-17149] #21686

Closed
spring-projects-issues opened this issue Aug 8, 2018 · 1 comment
Closed

@Bean in @TestConfiguration is ignored [SPR-17149] #21686

spring-projects-issues opened this issue Aug 8, 2018 · 1 comment
Assignees
Labels
in: test status: declined

Comments

@spring-projects-issues
Copy link
Collaborator

@spring-projects-issues spring-projects-issues commented Aug 8, 2018

Maksym Novoseltsev opened SPR-17149 and commented

I have faced an issue that @Bean that defined in the @TestConfiguration is never created and actually ignored. This applies only when you use @Import annotation to include @TestConfiguration in your test. When @TestConfiguration is defined as inner static class, everything works as expected.

Please, see Reference URL for demo project example.

BTW, @MockBean works correctly in both cases.


Affects: 5.0.8

Reference URL: https://github.com/mnovoseltsev/testconfiguration-bug

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Aug 9, 2018

Sam Brannen commented

To the best of my knowledge, @TestConfiguration classes must either be top-level classes or static nested classes.

In any case, the features you are referring to (e.g., @TestConfiguration and @Import in test classes) are part of Spring Boot Test and not supported in Core Spring (i.e., this JIRA issue tracker).

Thus, if making your @TestConfiguration either a top-level or static nested class does not solve your problem, please open an issue with the Spring Boot project instead.

I am therefore closing this issue.

@spring-projects-issues spring-projects-issues added type: bug status: declined in: test labels Jan 11, 2019
@spring-projects-issues spring-projects-issues removed the type: bug label Jan 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: test status: declined
Projects
None yet
Development

No branches or pull requests

2 participants