gpt4 book ai didi

testing - 将 Gebish 集成到 Gradle 中

转载 作者:行者123 更新时间:2023-11-28 21:27:25 24 4
gpt4 key购买 nike

我正在尝试将 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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com