3

Spring Boot (SpringBoot ランナーなしでクラシック WAR にパック) を使用しており、Spock に統合テストを実装したいと考えています。私が使用すると@ContextConfiguration(classes = MySpringConfiguration.class)、「標準」Spring コンテキストのみが使用されます (たとえば、@EnableConfigurationProperties.

4

1 に答える 1

7
@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
    }

}

スポック大好き!

アップデート

@giladが言ったように、これはSpring Boot 1.3+では必要ありません

于 2014-01-10T09:02:58.943 に答える