File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed
spring-boot-docs/src/main/asciidoc Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -2000,6 +2000,27 @@ in order to run your integration tests using random ports. For example:
20002000See <<howto-discover-the-http-port-at-runtime>> for a description of how you can discover
20012001the actual port that was allocated for the duration of the tests.
20022002
2003+ [[boot-features-testing-spring-boot-applications-with-spock]]
2004+ ==== Using Spock to test Spring Boot applications
2005+
2006+ If you wish to use Spock to test a Spring Boot application then you cannot use the
2007+ `@SpringApplicationConfiguration` annotation that was
2008+ <<boot-features-testing-spring-boot-applications,described above>> as Spock
2009+ https://code.google.com/p/spock/issues/detail?id=349[does not find the
2010+ `@ContextConfiguration` meta-annotation]. To work around
2011+ this limitation, you should use the `@ContextConfiguration` annotation directly and
2012+ configure it to use the Spring Boot-specfic context loader:
2013+
2014+ [source,groovy,indent=0]
2015+ ----
2016+ @ContextConfiguration(loader = SpringApplicationContextLoader.class)
2017+ class ExampleSpec extends Specification {
2018+
2019+ // ...
2020+
2021+ }
2022+ ----
2023+
20032024
20042025
20052026[[boot-features-test-utilities]]
You can’t perform that action at this time.
0 commit comments