我有一个集成测试,用于测试Webflow,只要它在要测试的 Controller 代码中达到某个点,就会看到类似以下的错误:
org.springframework.webflow.execution.ActionExecutionException: Exception thrown executing org.codehaus.groovy.grails.webflow.engine.builder.ClosureInvokingAction@ac0e86f in state 'blahQuestions' of flow 'blahBlah' -- action execution attributes were 'map[[empty]]'
at grails.test.WebFlowTestCase.signalEvent(WebFlowTestCase.groovy:142)
at com.blah1.blah2.blah3.blah4.BlahFlowIntegrationTests.testblahQuestions(BlahFlowIntegrationTests.groovy:91)
Caused by: groovy.lang.MissingPropertyException: No such property: blahMessage for class: org.springframework.webflow.core.collection.LocalAttributeMap
at com.blah1.blah2.blah3.blah4.BlahController$_closure2_closure15_closure22.doCall(BlahController.groovy:178)
由有问题的片段抛出:
flow.blahMessage = ''
,其中flow.put('blahMessage', '')
正常运行。仅当我从命令行运行测试时才会发生这种情况:grails test-app integration:
,测试从Eclipse RightClick on test -> Run As -> Grails Command (test-app)
运行正常。Grails 2.2.3
为什么会发生这种情况,我该如何解决?
更新:
当我通过命令行本身运行测试时,测试将通过,但如果运行所有集成测试,则测试将失败。
最佳答案
我的编辑似乎证明这是测试污染,“当我通过命令行本身运行测试时,测试将通过,但是如果我运行所有集成测试,则测试将失败”。列出其他集成测试,在其中使用@TestFor
和@Mock
,您应该只在单元测试中使用它们。
我通过遵循Ted Naleid的article“修复隔离通过但在作为套件运行时失败而通过的Grails测试”来解决这个问题。正是发生的事情。本文提供了一个常规类,您可以使用它来找到仍然无法通过测试的最小测试组合。
关于grails - 在命令行的Webflow集成测试中未添加Grails\Groovy语法Sugar,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27426469/