testing - 将 Gebish 集成到 Gradle 中

标签 testing gradle groovy geb

我正在尝试将 Gebish 集成到 Gradle 中。 我已经找到了这个不错的教程:http://www.gebish.org/manual/0.9.2/build-integrations.html#gradle

发现是我想用命令行指定浏览器。 现在我有了这段代码:

def gebVersion = '0.13.1'
def seleniumVersion = '2.51.0'

apply plugin: 'groovy'

repositories {
    mavenCentral()
}

dependencies {
    testCompile "org.gebish:geb-spock:$gebVersion"
    testCompile("org.spockframework:spock-core:1.0-groovy-2.4")

    testRuntime "org.seleniumhq.selenium:selenium-support:$seleniumVersion"

    /*
    // Drivers
    testCompile "org.seleniumhq.selenium:selenium-chrome-driver:$seleniumVersion"
    testCompile "org.seleniumhq.selenium:selenium-firefox-driver:$seleniumVersion"
    */
}

task firefoxTest(type: Test) {
    dependencies {
        testCompile "org.seleniumhq.selenium:selenium-firefox-driver:$seleniumVersion"
    }
}

task chromeTest(type: Test) {
    dependencies {
        testCompile "org.seleniumhq.selenium:selenium-chrome-driver:$seleniumVersion"
    }
}

test {
    systemProperties "geb.build.reportsDir": "$reportsDir/geb"
}

我还有一个位于 src/test/groovy/test.groovy 的大测试

import geb.Browser

Browser.drive {
    go "http://stackoverflow.com"
}

问题是,如果我使用 gradlew firefoxTestgradlew chromeTest 运行 gradle,它什么也没有发生,我收到以下消息:

14:02:03: Executing external task 'chromeTest'...
:compileJava UP-TO-DATE
:compileGroovy UP-TO-DATE
:processResources UP-TO-DATE
:classes UP-TO-DATE
:compileTestJava UP-TO-DATE
:compileTestGroovy
:processTestResources UP-TO-DATE
:testClasses
:chromeTest

BUILD SUCCESSFUL

Total time: 2.534 secs
14:02:05: External task execution finished 'chromeTest'.

如何使用特定浏览器通过命令行运行我的测试? 也可以内置 Browserstack 支持吗?

最佳答案

看起来您已正确设置 Gradle。但是,您的大型测试需要扩展 geb.spock.GebReportingSpecgeb.junit4.GebReportingTest 才能被测试运行程序检测为测试。然后它必须包含符合规范或测试要求的测试。例如,参见 GebishOrgSpec.groovyGebishOrgTest.groovy在 Geb Gradle 示例项目中。

关于testing - 将 Gebish 集成到 Gradle 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36036539/

相关文章:

javascript - MemoryRouter 没有设置位置的搜索部分

eclipse - spring boot 使用 springloaded 在 gradle 中没有工作

Jenkinsfile 很好地打印参数

android - 使用 JSON 在 Groovy/Grails 中创建对象

python - 将自己的测试方法名称注入(inject) pytest 输出

xml - 在 QTP 中从 Oracle 数据库中检索 XML 类型的记录

java - 如何使用 Java 使用 REST API 从 HP ALM 获取测试实例?

gradle - Gradle 1.2-在Linux上运行正常但在Windows上不运行的任务

maven - travis-ci 中构建的 Github Gradle 项目如何访问通常在我的本地 Maven 存储库中找到的依赖项?

jenkins - 访问 Jenkins 管道中的工作区