我正在尝试将 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 firefoxTest
或 gradlew 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.GebReportingSpec
或 geb.junit4.GebReportingTest
才能被测试运行程序检测为测试。然后它必须包含符合规范或测试要求的测试。例如,参见 GebishOrgSpec.groovy和 GebishOrgTest.groovy在 Geb Gradle 示例项目中。
关于testing - 将 Gebish 集成到 Gradle 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36036539/