问题
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