grails - 从 Spock 规范中提取规范

标签 grails spock

有没有办法从打印在文件中的 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

最佳答案

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

关于grails - 从 Spock 规范中提取规范,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13690778/

相关文章:

grails - 如何指定Spock测试环境?

grails - Grails-Spring Security Core和Spring Security ui插件不一致-无法使用新创建的用户登录

grails - Grails 2.4.4中的Spring Security插件问题

java - spock - 模拟静态方法不起作用

java - 如何模拟带注释的类?

gradle - 在Gradle中更改截断设置

facebook - Grails:运行 war 和运行应用程序之间的行为差​​异

grails - 如何将 HTML 表格数据从 View 传递到 grails 中的 Controller ?

java - Spock Spring 通过构造函数注入(inject)模拟和 bean

java - 从同一目录中的文件读取