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
894d86de
Commit
894d86de
authored
Aug 02, 2016
by
Ben Ooms
Committed by
Andy Wilkinson
Aug 16, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve documentation for testing with Spock
parent
17527738
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
1 deletion
+29
-1
spring-boot-features.adoc
spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc
+29
-1
No files found.
spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc
View file @
894d86de
...
@@ -5372,8 +5372,36 @@ on Spock's `spock-spring` module to your application's build. `spock-spring` int
...
@@ -5372,8 +5372,36 @@ on Spock's `spock-spring` module to your application's build. `spock-spring` int
Spring's test framework into Spock.
Spring's test framework into Spock.
NOTE: The annotations <<boot-features-testing-spring-boot-applications,described above>>
NOTE: The annotations <<boot-features-testing-spring-boot-applications,described above>>
can be used with Spock, i.e. you can annotate your `Specification` with
can be used with Spock
1.1
, i.e. you can annotate your `Specification` with
`@SpringBootTest` to suit the needs of your tests.
`@SpringBootTest` to suit the needs of your tests.
When using Spock 1.0 @SpringbootTest will not work for a web project. You need to use
'@SpringApplicationConfiguration()' and '@WebIntegrationTest(randomPort = true)'
If you want to autowire a TestRestTemplate you will have to create a bean like:
[source,java,indent=0]
----
public class TestConfiguration {
@Autowired
ApplicationContext applicationContext;
@Bean
TestRestTemplate restTemplate(){
RestTemplateBuilder builder = getRestTemplateBuilder(applicationContext);
TestRestTemplate template = new TestRestTemplate(builder.build());
template.setUriTemplateHandler(
new LocalHostUriTemplateHandler(applicationContext.getEnvironment()));
return template;
}
private RestTemplateBuilder getRestTemplateBuilder(
ApplicationContext applicationContext) {
try {
return applicationContext.getBean(RestTemplateBuilder.class);
}
catch (NoSuchBeanDefinitionException ex) {
return new RestTemplateBuilder();
}
----
...
...
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