Add auto imports for integration testing
JUnit tests can now be @SpringApplicationConfiguration and @IntegrationTest without any explicit imports. Also makes @RunWith(SpringJUnit4ClassRunner) optional. Fixes gh-969
This commit is contained in:
23
spring-boot-cli/test-samples/integration.groovy
Normal file
23
spring-boot-cli/test-samples/integration.groovy
Normal file
@@ -0,0 +1,23 @@
|
||||
@SpringApplicationConfiguration(classes=Application)
|
||||
@IntegrationTest
|
||||
class BookTests {
|
||||
@Autowired
|
||||
Book book
|
||||
@Test
|
||||
void testBooks() {
|
||||
assertEquals("Tom Clancy", book.author)
|
||||
}
|
||||
}
|
||||
|
||||
@Configuration
|
||||
class Application {
|
||||
@Bean
|
||||
Book book() {
|
||||
new Book(author: "Tom Clancy", title: "Threat Vector")
|
||||
}
|
||||
}
|
||||
|
||||
class Book {
|
||||
String author
|
||||
String title
|
||||
}
|
||||
Reference in New Issue
Block a user