首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Grails 2.3.5。当使用"test-app“而不是"test-app functional:”时,功能测试中的基本URL发生了变化。

Grails 2.3.5。当使用"test-app“而不是"test-app functional:”时,功能测试中的基本URL发生了变化。
EN

Stack Overflow用户
提问于 2014-02-21 00:38:31
回答 1查看 524关注 0票数 1

我正在为一个用Grails 2.3.5创建的大型web应用程序编写回归测试。单元测试使用spock框架,集成测试使用JUnit框架,功能测试使用spock和geb。DbUnit与集成和功能测试一起使用,以提供一个简单的数据库进行测试。调用以下命令时,所有测试都运行正常:

代码语言:javascript
复制
grails test-app unit:
grails test-app functional:
grails test-app unit: functional:
grails test-app integration: functional:
grails test-app unit: aUnitTest integration: aTestController functional:

但是当我打电话的时候:

代码语言:javascript
复制
grails test-app
grails test-app unit: integration: functional:

功能测试失败,错误如下:

代码语言:javascript
复制
junit.framework.AssertionFailedError: Condition not satisfied:

driver.currentUrl == urlPrefix + "/login"
|      |          |  |         |
|      |          |  |         http://localhost:8099/FOOBAR/login
|      |          |  http://localhost:8099/FOOBAR
|      |          false
|      |          19 differences (75% similarity)
|      |          http://localhost:8099/(GrailsUnitTestMixin)/login
|      |          http://localhost:8099/(FOOBAR)/login
|      http://localhost:8099/GrailsUnitTestMixin/login
FirefoxDriver: firefox on XP (c9e919fe-1046-488a-af0f-25e9a572db3b)

at MySpec.Login with username and invalid password(MySpec.groovy:31)

如您所见,基本URL的更改会导致测试失败。这可能是什么原因造成的?有没有关于从哪里开始寻找的想法?内存中的数据库当前设置为create-drop,因此它应该在单元测试、集成测试和功能测试之间清除。DbUnit连接在Bootstrap.groovy中,它在应用程序运行之前和之后启动和拆卸。任何帮助我们追踪这件事的人都会非常感谢。

这些文章是我能找到的最接近我的问题的文章:

Grails Spock integration test redirectedUrl different between localhost test-app and build server test-app

grails "test-app" fails for functional geb+spock test but "test-app -functional" is successfull

EN

回答 1

Stack Overflow用户

发布于 2014-02-22 04:23:07

在这里,测试阶段之间肯定存在一些全局状态溢出。我唯一的建议是观察上下文路径在哪一点更改为包含GrailsUnitTextMixin。是当你点击链接的时候吗?或者你会被重定向到那个url?在调试模式下运行测试,并尝试跟踪它。

将上下文设置为在单元测试中使用@TestFor时使用的类名的事实表明,在单元测试阶段会设置或修改某些全局/静态变量,但您说如果同时运行单元测试和功能测试,则不会观察到这种行为,并且只有在同时运行所有三个测试阶段时才会得到这种行为……

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/21914037

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档