【问题标题】:No such property: appCtx for class: groovy.lang.Binding - Cucumber, Grails没有这样的属性:appCtx 类:groovy.lang.Binding - Cucumber,Grails
【发布时间】:2014-04-12 13:40:29
【问题描述】:


我正在使用 Grails 2.3.3 和 Cucumber 0.10.0,我正在尝试创建由插件作者创建的此示例的更新版本:https://github.com/hauner/grails-cucumber/wiki/Testing-Grails-with-Cucumber-and-Geb
我遇到的问题是,对于新的 Grails,appCtx 不再绑定,黄瓜需要它。作者在他的 github 中对此进行了讨论:

“appCtx 的问题是,它不再在 grails 2.3 的绑定中。您可以使用 Holders.applicationContext 或使用 Holders.applicationContext 设置 appCtx 来解决它。这就是插件 2.3 release 将增加与我的旧示例的兼容性。”


我已将 CucumberTestType.groovy 更改为看起来像他在最新分支版本上的那个。

private Binding createBinding () {
    Map variables = buildBinding.variables.clone () as Map
    variables.remove ("metaClass")
    variables.remove ("getMetaClass")
    variables.remove ("setMetaClass")
    setAppCtx (variables)
    setFunctionalTestBaseUrl (variables)
    new Binding (variables)
}

private void setAppCtx (Map variables) {
    // appCtx is no longer available in the (test-app) binding since grails 2.3

    // for plugin backward compatibility we add it if possible, i.e. not forked!
    if (!forked && !variables.containsKey('appCtx')) {
        variables.put('appCtx', getApplicationContext())
    }
}

但即使在此之后,我仍然收到相同的错误:
Error executing script TestApp: cucumber.runtime.CucumberException: groovy.lang.MissingPropertyException: No such property: appCtx for class: groovy.lang.Binding (Use --stacktrace to see the full trace)

我是不是误解了作者的意思,因此遗漏了什么?

【问题讨论】:

    标签: grails cucumber


    【解决方案1】:

    我发布了包含 grails 2.3 支持的 0.11.0-SNAPSHOT 版本的插件。

    我还将示例项目 (https://github.com/hauner/grails-cucumber/tree/master/test/projects) 更新为 0.11.0-SNAPSHOT 和 grails 2.3.7。

    geb 示例现在使用最新版本的 geb 和 webdriver。 ListPage 中还有一个小的代码更改。 url 应该是 book/index 而不是 book/list

    要使用 fork 模式,您至少需要 grails 2.3.8。

    希望有帮助:)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-01-06
      • 2019-02-10
      • 1970-01-01
      • 2019-02-10
      • 2011-04-15
      • 2023-03-22
      • 1970-01-01
      • 2016-08-28
      相关资源
      最近更新 更多