繁体   English   中英

如何在Spring Boot中配置集成测试

[英]How to configure integration tests in Spring Boot

我正在使用Spring Boot(没有SpringBoot运行器打包到经典WAR),我想在Spock中实现集成测试。 当我使用@ContextConfiguration(classes = MySpringConfiguration.class)只使用“标准”Spring上下文(没有Boot的任何好处,例如@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
    }

}

我喜欢Spock!

更新

正如@gilad所说, Spring Boot 1.3+不需要这样做

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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