【发布时间】:2012-06-04 03:36:25
【问题描述】:
我正在尝试在 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 文件。步骤 def 位于 test/functional/steps 中并包含:
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")
}
在 test/functional/setup 中还有一个 shared_driver.groovy 类,它是为直接 Groovy 测试而创建的,我不确定是否仍然需要它。
运行配置命令为:test-app --stacktrace,VM 选项:-Dgeb.env=chrome
任何帮助表示赞赏,谢谢!
【问题讨论】:
-
刚刚注意到环境关闭开始大括号后的“不确定” - 这实际上不在代码中!
-
我通过注释掉 GebConfig.groovy 中的 environment{} 部分解决了这个问题,这似乎是给定错误的问题。现在一切都好。还是谢谢!
-
当 geb-spock 集成的文档记录如此详尽时,为什么还要使用 cucumber?
标签: grails groovy geb cucumber-jvm