Geb + Spock +常规设置

时间:2012-12-06 16:46:18

标签: groovy gradle spock geb

所以我一直试图让这些工具一起运行,但我似乎无法正确设置。每次出现以下错误:

The project was not built since its build path is incomplete. Cannot find the class file for org.spockframework.mock.MockController. Fix the build path then try building this project.

我创建了这个gist。当我运行gradle chrome测试时,我得到以下输出:

 gradle chrome test
 :compileJava UP-TO-DATE
 :compileGroovy UP-TO-DATE
 :processResources UP-TO-DATE
 :classes UP-TO-DATE
 :compileTestJava UP-TO-DATE
 :compileTestGroovy FAILED

 FAILURE: Build failed with an exception.
 * What went wrong:
 Execution failed for task ':compileTestGroovy'.
 > org/spockframework/mock/MockController

 * Try:
 Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

 BUILD FAILED

我正在使用gradle 1.3,geb 0.7.2和spock 0.7-groovy-2.0。我也尝试更新geb以使用0.9.0-RC-1。上面的要点应该包含看到同样错误所需的一切。

2 个答案:

答案 0 :(得分:6)

这是你运行Spock 0.7时Geb版本低于0.9.0-RC-1(与Spock 0.7不兼容)的结果。仔细检查您的设置并执行干净的构建。

答案 1 :(得分:0)

我遇到了同样的问题。事实证明你需要使用groovy 1.8版本,因为Geb / Spock集成jar还没有升级到groovy 2.0。以下设置对我有用:

dependencies {

    def seleniumVersion = "2.42.2"
    def phantomJsVersion = '1.1.0'
    def cargoVersion = '1.4.9'

    // selenium drivers
    compile "org.seleniumhq.selenium:selenium-ie-driver:$seleniumVersion"
    compile "org.seleniumhq.selenium:selenium-chrome-driver:$seleniumVersion"
    compile "org.seleniumhq.selenium:selenium-firefox-driver:$seleniumVersion"
    compile "org.seleniumhq.selenium:selenium-support:$seleniumVersion"
    compile("com.github.detro.ghostdriver:phantomjsdriver:$phantomJsVersion") {
        transitive = false
    }

    // geb
    compile 'org.codehaus.geb:geb-core:0.7.2'
    compile 'org.codehaus.geb:geb-spock:0.7.2'

    // spock
    compile 'org.spockframework:spock-core:0.6-groovy-1.8'

    compile 'junit:junit:4.8.2'
    compile 'org.slf4j:slf4j-log4j12:1.7.6@jar'
    compile 'org.slf4j:slf4j-api:1.7.6@jar'

}

我在我的博客上发布了包含货物整合的完整脚本:http://www.openscope.net/2015/02/21/how-to-configure-gebspock-with-gradle/