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
5677b222
Commit
5677b222
authored
Apr 11, 2016
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Document using @TestConfiguration to customize app's primary config
Closes gh-5566
parent
69499bf3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
2 deletions
+7
-2
spring-boot-features.adoc
spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc
+7
-2
No files found.
spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc
View file @
5677b222
...
@@ -4442,14 +4442,19 @@ to load. Alternatively, you might have often used nested `@Configuration` classe
...
@@ -4442,14 +4442,19 @@ to load. Alternatively, you might have often used nested `@Configuration` classe
your test.
your test.
When testing Spring Boot applications this is often not required.
When testing Spring Boot applications this is often not required.
Spring Boot's `@*Test` annotations will search for your primary configuration
automatically
Spring Boot's `@*Test` annotations will search for your primary configuration
whenever you don't explicitly defined
one.
automatically whenever you don't explicitly define
one.
The search algorithm works up from the package that contains the test until it finds a
The search algorithm works up from the package that contains the test until it finds a
`@SpringBootApplication` or `@SpringBootConfiguration` annotated class. As long as you've
`@SpringBootApplication` or `@SpringBootConfiguration` annotated class. As long as you've
<<using-boot-structuring-your-code, structure your code>> in a sensible way your main
<<using-boot-structuring-your-code, structure your code>> in a sensible way your main
configuration is usually found.
configuration is usually found.
If you want to customize the primary configuration, you can use a nested
`@TestConfiguration` class. Unlike a nested `@Configuration` class which would be used
instead of a your application's primary configuration, a nested `@TestConfiguration` class
will be used in addition to your application's primary configuration.
NOTE: Spring's test framework will cache application contexts between tests. Therefore, as
NOTE: Spring's test framework will cache application contexts between tests. Therefore, as
long as your tests share the same configuration (no matter how it's discovered), the
long as your tests share the same configuration (no matter how it's discovered), the
potentially time consuming process of loading the context will only happen once.
potentially time consuming process of loading the context will only happen once.
...
...
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