首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >从Spock规范中提取规范

从Spock规范中提取规范
EN

Stack Overflow用户
提问于 2012-12-04 04:03:44
回答 1查看 626关注 0票数 3

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

例如,对于以下等级库:

代码语言:javascript
复制
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
    }
}

应打印如下内容:

代码语言:javascript
复制
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
EN

回答 1

Stack Overflow用户

发布于 2012-12-04 04:44:40

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

票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/13690778

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档