selenium - 如何排除 Geb 中的测试?

标签 selenium groovy integration-testing spock geb

我正在将 Geb 与 Spock 一起使用,并且我想引入测试标记。在 Spock 中使用以下语法可以轻松实现:

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

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

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

最佳答案

由于您使用的是 spock,因此您可以在类或方法级别使用 @IgnoreIf。

这是一篇关于它的好文章: http://mrhaki.blogspot.com/2014/06/spocklight-ignore-specifications-based.html

由于您拥有它的系统属性,因此您应该能够直接将其插入:

@IgnoreIf({ !System.properties.containsKey("test.include.slow") })

关于selenium - 如何排除 Geb 中的测试?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35343413/

相关文章:

c# - 下拉没有 id 也没有名字

Grails 3 集成规范具有奇怪的事务行为

unit-testing - Jacoco for IntegrationTests 的代码覆盖率报告在 Weblogic 服务器上运行

java - Jenkins Selenium 插件初始化失败

c# - 如何在 C# 中使用 Selenium 定位表格中的文本并引用元素单击另一个元素?

testing - 最新的 Groovy 稳定版本令人费解的问题

testing - 使用 groovy 使 soapUI 测试用例失败但不中止

grails - 示例 Grails Web 应用程序 : upload file, 处理它,下载

node.js - TestCafe:将测试从另一个文件导入到当前夹具中

java - 如何对 BigDecimal 值进行加法?