【问题标题】:Extract specifications from Spock specs从 Spock 规范中提取规范
【发布时间】:2012-12-03 20:03:43
【问题描述】:

有没有办法从我打印在文件中的 Spock 测试中获取规范(过滤代码)?

例如,对于以下规范:

class CarSpec extends IntegrationSpec {

    def 'it should not retrieve deleted cars'() {
        given: 'a car'
            def car = new Car(uniqueName: 'carName')
            car.save()
        when: 'I delete the car'
            car.delete()
        then: 'it shouldn't find me the car on the DB'
            Car.find { uniqueName == 'carName' } == null
    }
}

应该打印如下内容:

CarSpec
    it should not retrieve deleted cars
        given a car
        when I delete the car
        then it shouldn't find me the car on the DB

【问题讨论】:

    标签: grails spock


    【解决方案1】:

    您可以使用可用的第三方插件之一(例如https://github.com/damage-control/report),或编写自己的 Spock 扩展程序(请参阅https://github.com/spockframework/smarter-testing-with-spock/tree/master/src/test/groovy/extension/custom)。

    【讨论】:

    • 您有关于如何使用损坏控制插件的说明吗? README 文件似乎不够清晰。
    • 我注意到您是spock.lang.@Issue 的作者 - 有没有一种简单的方法可以让损坏控制报告包含报告中的链接?
    • 你得问问损害控制报告的作者。
    猜你喜欢
    • 1970-01-01
    • 2014-06-30
    • 2011-08-02
    • 1970-01-01
    • 2015-08-20
    • 1970-01-01
    • 2021-01-19
    • 2012-05-22
    相关资源
    最近更新 更多