尝试使用cucumber-jvm运行geb测试时出错

时间:2012-06-04 03:36:25

标签: grails groovy geb cucumber-jvm

我正在尝试在IntelliJ中的Grails项目中运行一些geb测试但是遇到了麻烦&经过2天的网络搜索和尝试不同的事情仍然卡住了。我们确实有一些Groovy测试运行良好,以前,但到目前为止没有运气与geb.我们正在使用cucumber-jvm。

目前我收到以下错误:     执行脚本TestApp时出错错误:groovy.lang.MissingMethodException:     没有方法签名:GebConfig.environments()适用于参数类型:     (GebConfig $ _run_closure2)值:[GebConfig $ _run_closure2 @ 4ad3727e]

我的GebConfig.groovy文件处于测试/功能状态,包含:

import org.openqa.selenium.htmlunit.HtmlUnitDriver
import org.openqa.selenium.firefox.FirefoxDriver
import org.openqa.selenium.chrome.ChromeDriver

// Use htmlunit as the default
// See: http://code.google.com/p/selenium/wiki/HtmlUnitDriver
driver = {
    def driver = new HtmlUnitDriver()
    driver.javascriptEnabled = true
    driver
}

environments {Not sure 
    chrome {-Dgeb.env=chrome
        driver = { new ChromeDriver() }
    }
    firefox {
        driver = { new FirefoxDriver() }
    }
}

我的.feature文件也在test / functional中。步骤def是在测试/功能/步骤&包含:

package steps

import geb.*

this.metaClass.mixin (cucumber.runtime.groovy.EN)
this.metaClass.mixin (cucumber.runtime.groovy.Hooks)

def browser = new Browser()

Given (~"I am on the front page") {
    browser.go("http://localhost:8081/whereisOne")
}

在测试/功能/设置中还有一个shared_driver.groovy类,它是为直接的Groovy测试创建的,&我不确定是否还需要它。

run config命令是:test-app --stacktrace,带有VM选项:-Dgeb.env = chrome

感谢任何帮助,谢谢!

1 个答案:

答案 0 :(得分:0)

代码中的-Dgeb.env = chrome?如果是这样,您必须删除此行。其他一切看起来都不错。

相关问题