Extract specifications from Spock specs

北城余情 提交于 2019-12-07 16:48:14

问题


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

回答1:


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).



来源:https://stackoverflow.com/questions/13690778/extract-specifications-from-spock-specs

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!