如何排除Geb中的测试?

时间:2016-02-11 15:29:00

标签: selenium groovy integration-testing spock geb

我正在使用Geb和Spock,我想引入测试标记。使用语法在Spock中很容易实现:

runner {
  if (!System.properties.containsKey('test.include.slow')) {
    exclude Slow
  }
}

如果找不到@Slow属性,这将排除使用test.include.slow注释的所有测试。不幸地将exclude放入GebConfig.groovy并不是真的这样做,因为那里没有这样的方法。

有没有办法在Geb中使用这个exclude方法?

2 个答案:

答案 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特定的配置。