【问题标题】:Ignore test based on navigator(pock framework)基于navigator的忽略测试(pock框架)
【发布时间】:2016-08-09 09:32:08
【问题描述】:

我想在 chrome 中启动一些测试,在 Firefox 中启动其他测试,

如何使用 spock 扩展标记此测试以忽略依赖于导航器?有可能吗?

提前致谢

【问题讨论】:

  • 您在使用 Geb 吗?需要更多信息。
  • 是的,我使用 Geb 框架

标签: testing groovy spock


【解决方案1】:

您可以使用@IgnoreIf@Requires 标签,用于测试用例是否运行。因此,根据该条件,您可以决定您的案例将启动 chrome 还是 firefox。

class SampleRequiresSpec extends Specification {

private static boolean isOsWindows() {
    System.properties['os.name'] == 'windows'
}

@IgnoreIf({ Boolean.valueOf(properties['spock.ignore.longRunning']) })
def "run spec if Java system property 'spock.ignore.longRunning' is not set or false"() {
    expect:
    true
}

@IgnoreIf({ Boolean.valueOf(env['SPOCK_IGNORE_LONG_RUNNING']) })
def "run spec if environment variable 'SPOCK_IGNORE_LONG_RUNNING' is not set or false"() {
    expect:
    true
}

@IgnoreIf({ javaVersion < 1.7 })
def "run spec if run in Java 1.7 or higher"() {
    expect:
    true
}

@IgnoreIf({ javaVersion != 1.7 })
def "run spec if run in Java 1.7"() {
    expect:
    true
}

@IgnoreIf({ isOsWindows() })
def "run only if run on non-windows operating system"() {
    expect:
    true
}
@Requires({ isOsWindows })
def 'should run only on Windows'() {
    expect:
    true
}

}

【讨论】:

    猜你喜欢
    • 2013-10-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-05-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多