-
Notifications
You must be signed in to change notification settings - Fork 40.2k
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
Top level @TestConfiguration classes should be picked up by SpringBootTest #6769
Comments
@TestConfiguration
classes @TestConfiguration
classes should be picked up by SpringBootTest
@TestConfiguration
classes should be picked up by SpringBootTest
This is the documentation for
It's clearly stated that you can't use that with top-level class. What's wrong with Can you show what the base class and sub-class looks like (in particular which test annotations are present on them? |
Sure. Here are the two classes.
Nothing wrong actually. It's just that in my opinion marking a top level class with
That part is clear, but whats is not perfectly clear is what is written a paragraph later:
So what's the purpose of such classes then? To be used with Anyway this is more of a proposal for enhancement. As you pointed out, it is indeed documented that |
I think it might be a little confusing to have @TestConfiguration(excludeFromScan=false) |
How about disabling it when it's a top-level class? That way, there's only one semantic and the name fits quite well. |
@snicoll do you mean the current behavior? Unless you mean something else please feel free to close this. Looks like I misunderstood how
It is indeed a little confusing. To admit I was a bit confused what is the difference between nested |
Hi @plamentotev, I'm also confused with the document. And I don't know how to solve my problem neither. My situation is, there's a configuration and I want to replace it with another configuration during testing. I don't know how to do it. |
I came here because I was looking whether there was an open bug for In my opinion the documentation is slightly confusing (see 3 people in this issue who misunderstood it). |
A +1 from me on the confusing documentation (which also led me to discover this issue). Especially the wording "@TestComponent and @TestConfiguration are only needed on top level classes." following right after the statement "you can use a nested @TestConfiguration class" left me utterly confused about its purpose. "are only needed" to me suggests that you would never use them on inner classes, which seems wrong. |
@jkuipers I assume you meant |
Oops: that's indeed what I intended to say. I'll update my former comment. Thanks for confirming that at least my understanding is correct now. |
Actually, this became a duplicate of #8421 |
My |
@hantsy this issue is closed and we don't use the tracker for questions. |
Hi,
I'm using Spring Boot 1.4.0 with
spring-boot-starter-web
andspring-boot-starter-test
starters. I would like to be able to configure additional beans that should be available only to test classes. But using top-level@TestConfiguration
does not work - I expected that this way the test configuration should be shared by all test classes, but in fact it's just ignored.The other way to share
@TestConfiguration
classes - that is to define a static inner-class@TestConfiguration
inside base class, does not work either. The classes that extend the base class does not pick the inner@TestConfiguration
class. I think this would be nice addition - this way you can share the same test configuration between a group of test classes that share the same base class - for example I have base class for all integration tests. This way I could add additional configuration that is only applied to the integration testes.The text was updated successfully, but these errors were encountered: