【问题标题】:Geb functional tests in Grails fail because the web application has not been startedGrails 中的 Geb 功能测试失败,因为 Web 应用程序尚未启动
【发布时间】:2010-12-12 18:24:38
【问题描述】:

我正在尝试 Geb (0.5.1) Grails (1.3.5) 集成。使用 JUnit 运行器(扩展 grails.plugin.geb.GebTests)时,Web 应用程序在执行 Geb 测试之前不会启动。因此测试失败,Firefox 说它无法在 localhost:8090 建​​立与服务器的连接。

在同一个测试应用程序中运行功能性硒测试(selenium-rc 1.0.2 插件)运行没有问题。

有人知道为什么 grails Web 应用程序在 Geb 功能测试之前没有启动,而在 Selenium 功能测试中正确启动了吗?

import geb.*

class GebTests extends grails.plugin.geb.GebTests {

    void testIndexSearch() {
        Browser.drive("http://localhost:8090/agora") {
            go('/admin')
            assert title == 'the title'
        }
    }

}

【问题讨论】:

  • Ruben,这个测试在你的 Grails 项目的 test/functional 目录中吗?
  • 是的,测试在test/functional/xx/yy/zz目录下。

标签: grails groovy


【解决方案1】:

Browser.drive() 不应该是必需的。您是否尝试过以下方法?

import geb.*

class GebTests extends grails.plugin.geb.GebTests {
    void testIndexSearch() {
        go('/admin')
        assert title == 'the title'
    }
}

要设置 Grails 应用程序根目录以外的基本 URL,请添加:

String getBaseUrl() { "http://some/url" }

【讨论】:

  • 删除周围的 Browser.drive(){} 语句后,测试成功。谢谢
猜你喜欢
  • 2012-05-06
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多