Skip to content

Commit

Permalink
Document need to use @ContextConfiguration with Spock
Browse files Browse the repository at this point in the history
Closes #1167
  • Loading branch information
wilkinsona committed Jul 7, 2014
1 parent 3978700 commit 148e32d
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc
Expand Up @@ -2000,6 +2000,27 @@ in order to run your integration tests using random ports. For example:
See <<howto-discover-the-http-port-at-runtime>> for a description of how you can discover
the actual port that was allocated for the duration of the tests.

[[boot-features-testing-spring-boot-applications-with-spock]]
==== Using Spock to test Spring Boot applications

If you wish to use Spock to test a Spring Boot application then you cannot use the
`@SpringApplicationConfiguration` annotation that was
<<boot-features-testing-spring-boot-applications,described above>> as Spock
https://code.google.com/p/spock/issues/detail?id=349[does not find the
`@ContextConfiguration` meta-annotation]. To work around
this limitation, you should use the `@ContextConfiguration` annotation directly and
configure it to use the Spring Boot-specfic context loader:

[source,groovy,indent=0]
----
@ContextConfiguration(loader = SpringApplicationContextLoader.class)
class ExampleSpec extends Specification {
// ...
}
----



[[boot-features-test-utilities]]
Expand Down

0 comments on commit 148e32d

Please sign in to comment.