简体   繁体   中英

How to configure integration tests in Spring Boot

I'm using Spring Boot (packed to classic WAR without SpringBoot runner) and I'd like to implement integration tests in Spock. When I use @ContextConfiguration(classes = MySpringConfiguration.class) then only "standard" Spring context is used (without any benefits from Boot, like for example @EnableConfigurationProperties .

@ContextConfiguration(classes = Application, loader = SpringApplicationContextLoader)
class FooSpec extends Specification {

    @Autowired
    private CustomProperties customProperties;

    def "should read spring boot properties"() {

        when:
            def foo = customProperties.foo;
        then:
            foo
    }

}

I love Spock!

Update

As @gilad said, this is not needed in Spring Boot 1.3+

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM