Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
6bd6279e
Commit
6bd6279e
authored
Mar 21, 2019
by
Madhura Bhave
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Document slice test behavior with @Configuration classes
Closes gh-16274
parent
10e726ea
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
0 deletions
+32
-0
spring-boot-features.adoc
...ing-boot-docs/src/main/asciidoc/spring-boot-features.adoc
+32
-0
No files found.
spring-boot-project/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc
View file @
6bd6279e
...
@@ -7185,6 +7185,10 @@ NOTE: `@WebFluxTest` cannot detect routes registered via the functional web fram
...
@@ -7185,6 +7185,10 @@ NOTE: `@WebFluxTest` cannot detect routes registered via the functional web fram
testing `RouterFunction` beans in the context, consider importing your `RouterFunction`
testing `RouterFunction` beans in the context, consider importing your `RouterFunction`
yourself via `@Import` or using `@SpringBootTest`.
yourself via `@Import` or using `@SpringBootTest`.
NOTE: `@WebFluxTest` cannot detect custom security configuration registered via a `@Bean`
of type `SecurityWebFilterChain`. To include that in your test, you will need to import
the configuration that registers the bean via `@Import` or use `@SpringBootTest`.
TIP: Sometimes writing Spring WebFlux tests is not enough; Spring Boot can help you run
TIP: Sometimes writing Spring WebFlux tests is not enough; Spring Boot can help you run
<<boot-features-testing-spring-boot-applications-testing-with-running-server,
<<boot-features-testing-spring-boot-applications-testing-with-running-server,
full end-to-end tests with an actual server>>.
full end-to-end tests with an actual server>>.
...
@@ -7813,6 +7817,34 @@ NOTE: Depending on the complexity of your application, you may either have a sin
...
@@ -7813,6 +7817,34 @@ NOTE: Depending on the complexity of your application, you may either have a sin
approach lets you enable it in one of your tests, if necessary, with the `@Import`
approach lets you enable it in one of your tests, if necessary, with the `@Import`
annotation.
annotation.
Test slices exclude `@Configuration` classes from scanning. For example, for a `@WebMvcTest`,
the following configuration will not include the given `WebMvcConfigurer` bean in the application
context loaded by the test slice:
[source,java,indent=0]
----
@Configuration
public class WebConfiguration {
@Bean
public WebMvcConfigurer testConfigurer() {
return new WebMvcConfigurer() {
...
};
}
}
----
The configuration below will, however, cause the custom `WebMvcConfigurer` to be loaded
by the test slice.
[source,java,indent=0]
----
@Component
public class TestWebMvcConfigurer extends WebMvcConfigurer {
...
}
----
Another source of confusion is classpath scanning. Assume that, while you structured your
Another source of confusion is classpath scanning. Assume that, while you structured your
code in a sensible way, you need to scan an additional package. Your application may
code in a sensible way, you need to scan an additional package. Your application may
resemble the following code:
resemble the following code:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment