2012-12-03 105 views
3

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

回答

4

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

+0

你有没有关于如何使用损坏控制插件的说明?自述文件看起来不够清楚。 –

+0

最好问问作者。 –

+0

我注意到你是'spock.lang。@ Issue'的作者 - 是否有一个简单的方法让损害控制报告包含报告中的链接? – Bohemian