Skip to content

Commit bbe7415

Browse files
committed
Merge branch '3.0.x' into 3.1.x
Closes gh-38040
2 parents 56d9de6 + bded915 commit bbe7415

File tree

1 file changed

+5
-2
lines changed
  • spring-boot-project/spring-boot-docs/src/docs/asciidoc/features

1 file changed

+5
-2
lines changed

spring-boot-project/spring-boot-docs/src/docs/asciidoc/features/testing.adoc

+5-2
Original file line numberDiff line numberDiff line change
@@ -172,14 +172,17 @@ include::code:always/MyApplicationTests[]
172172
If your application uses component scanning (for example, if you use `@SpringBootApplication` or `@ComponentScan`), you may find top-level configuration classes that you created only for specific tests accidentally get picked up everywhere.
173173

174174
As we <<features#features.testing.spring-boot-applications.detecting-configuration,have seen earlier>>, `@TestConfiguration` can be used on an inner class of a test to customize the primary configuration.
175-
When placed on a top-level class, `@TestConfiguration` indicates that classes in `src/test/java` should not be picked up by scanning.
176-
You can then import that class explicitly where it is required, as shown in the following example:
175+
`@TestConfiguration` can also be used on a top-level class. Doing so indicates that the class should not be picked up by scanning.
176+
You can then import the class explicitly where it is required, as shown in the following example:
177177

178178
include::code:MyTests[]
179179

180180
NOTE: If you directly use `@ComponentScan` (that is, not through `@SpringBootApplication`) you need to register the `TypeExcludeFilter` with it.
181181
See {spring-boot-module-api}/context/TypeExcludeFilter.html[the Javadoc] for details.
182182

183+
NOTE: An imported `@TestConfiguration` is processed earlier than an inner-class `@TestConfiguration` and an imported `@TestConfiguration` will be processed before any configuration found through component scanning.
184+
Generally speaking, this difference in ordering has no noticeable effect but it is something to be aware of if you're relying on bean overriding.
185+
183186

184187

185188
[[features.testing.spring-boot-applications.using-application-arguments]]

0 commit comments

Comments
 (0)