Skip to content

Commit 148e32d

Browse files
committed
Document need to use @ContextConfiguration with Spock
Closes #1167
1 parent 3978700 commit 148e32d

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2000,6 +2000,27 @@ in order to run your integration tests using random ports. For example:
20002000
See <<howto-discover-the-http-port-at-runtime>> for a description of how you can discover
20012001
the 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]]

0 commit comments

Comments
 (0)