从Spock规范中提取规范 [英] Extract specifications from Spock specs
本文介绍了从Spock规范中提取规范的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有办法从打印在文件中的Spock测试中获取规范(过滤代码)?
例如,对于以下规范: class CarSpec extends IntegrationSpec {
$ b $ def'它不应该检索已删除的汽车'(){
给出:'a car'
def car = new Car(uniqueName:'carName')
car.save()
当:'我删除了车'
car.delete ()
then:'它不应该在数据库中找到我的车'
Car.find {uniqueName =='carName'} == null
}
}
应打印如下内容:
CarSpec
它不应该检索已删除的汽车
给出汽车
当我删除汽车
时,它不应该在数据库中找到我的汽车
解决方案
您可以使用其中一个可用的t第三方插件(例如 https://github.com/damage-control/report ),或者编写你自己的Spock扩展(参见 https://github.com/spockframework/smarter-testing-with-spock/tree/master/src/test/groovy/extension/custom )。
Is there a way to obtain specifications (filtering the code) from my Spock tests printed in a file?
For example, for the following spec:
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
}
}
should print something like:
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
解决方案
You could use one of the available third-party plugins (e.g. https://github.com/damage-control/report), or write your own Spock extension (see https://github.com/spockframework/smarter-testing-with-spock/tree/master/src/test/groovy/extension/custom).
这篇关于从Spock规范中提取规范的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文