我正在使用Geb和Spock,我想引入测试标记。使用语法在Spock中很容易实现:
runner {
if (!System.properties.containsKey('test.include.slow')) {
exclude Slow
}
}
如果找不到@Slow
属性,这将排除使用test.include.slow
注释的所有测试。不幸地将exclude
放入GebConfig.groovy
并不是真的这样做,因为那里没有这样的方法。
有没有办法在Geb中使用这个exclude
方法?
答案 0 :(得分:2)
由于你正在使用spock,你可以在类或方法级别使用@IgnoreIf。
这是一篇很好的文章: http://mrhaki.blogspot.com/2014/06/spocklight-ignore-specifications-based.html
由于你有一个系统属性,你应该只能将其插入:
@IgnoreIf({ !System.properties.containsKey("test.include.slow") })
答案 1 :(得分:0)
你走在正确的轨道上,但你应该把那个跑步者配置代码放在SpockConfig.groovy
而不是GebConfig.groovy
,因为它是Spock特定的配置。