Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/grails/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
无法为webFlow 2.0.0运行Grails集成测试_Grails_Spring Webflow_Grails Plugin_Grails 2.0 - Fatal编程技术网

无法为webFlow 2.0.0运行Grails集成测试

无法为webFlow 2.0.0运行Grails集成测试,grails,spring-webflow,grails-plugin,grails-2.0,Grails,Spring Webflow,Grails Plugin,Grails 2.0,我正在使用Grails2.0.3和webFlow 2.0.0 我的控制器中有一个WebFlow定义,它工作得很好,但我仍然希望添加集成测试,以便于将来的维护 每当控制器试图向流范围添加一些值时,我在测试中遇到以下异常: ERROR org.codehaus.groovy.grails.webflow.engine.builder.ClosureInvokingAction - Exception occured invoking flow action: No such property: p

我正在使用Grails2.0.3和webFlow 2.0.0

我的控制器中有一个WebFlow定义,它工作得很好,但我仍然希望添加集成测试,以便于将来的维护

每当控制器试图向流范围添加一些值时,我在测试中遇到以下异常:

ERROR org.codehaus.groovy.grails.webflow.engine.builder.ClosureInvokingAction  - Exception occured invoking flow action: No such property: poInfo for class: org.springframework.webflow.core.collection.LocalAttributeMap 
groovy.lang.MissingPropertyException: No such property: poInfo for class: org.springframework.webflow.core.collection.LocalAttributeMap 
        at com.psswm.inboundcal.ReceivingEventController$_closure1_closure6_closure12.doCall(ReceivingEventController.groovy:83) 
        at grails.test.WebFlowTestCase.signalEvent(WebFlowTestCase.groovy:143) 
        at com.psswm.inboundcal.ReceivingEventCreationFlowTests.testAddPoInfoMissingPiecesPallets(ReceivingEventCreationFlowTests.groovy:32) 
        at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45) 
        at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) 
        at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42) 
        at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20) 
        at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28) 
        at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:30) 
        at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263) 
        at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68) 
        at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47) 
        at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231) 
        at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60) 
        at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229) 
        at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50) 
        at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222) 
        at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28) 
        at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:30) 
        at org.junit.runners.ParentRunner.run(ParentRunner.java:300) 
        at org.junit.runners.Suite.runChild(Suite.java:128) 
        at org.junit.runners.Suite.runChild(Suite.java:24) 
        at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231) 
        at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60) 
        at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229) 
        at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50) 
        at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222) 
        at org.junit.runners.ParentRunner.run(ParentRunner.java:300) 
        at _GrailsTest_groovy$_run_closure4.doCall(_GrailsTest_groovy:290) 
        at _GrailsTest_groovy$_run_closure2.doCall(_GrailsTest_groovy:248) 
        at _GrailsTest_groovy$_run_closure1_closure21.doCall(_GrailsTest_groovy:195) 
        at _GrailsTest_groovy$_run_closure1.doCall(_GrailsTest_groovy:184) 
        at TestApp$_run_closure1.doCall(TestApp.groovy:82) 
| Failure:  testAddPoInfoMissingPiecesPallets(com.psswm.inboundcal.ReceivingEventCreationFlowTests) 
|  org.springframework.webflow.execution.ActionExecutionException: Exception thrown executing org.codehaus.groovy.grails.webflow.engine.builder.ClosureInvokingAction@3beff9ad in state 'addPO' of flow 'create' -- action execution attributes were 'map[[empty]]' 
        at grails.test.WebFlowTestCase.signalEvent(WebFlowTestCase.groovy:143) 
        at com.psswm.inboundcal.ReceivingEventCreationFlowTests.testAddPoInfoMissingPiecesPallets(ReceivingEventCreationFlowTests.groovy:32) 
Caused by: groovy.lang.MissingPropertyException: No such property: poInfo for class: org.springframework.webflow.core.collection.LocalAttributeMap 
        at com.psswm.inboundcal.ReceivingEventController$_closure1_closure6_closure12.doCall(ReceivingEventController.groovy:83) 
        ... 2 more

这是我尝试测试的WebFlow代码的一部分:

def createFlow = { 
    initialize { 
        action { 
            if (params.eventId) { 
                flow.receivingEventId = params.eventId as int 
                ReceivingEvent existingReceivingEvent = ReceivingEvent.get(flow.receivingEventId) 
                flow.receivingEvent = new ReceivingEvent(branch:existingReceivingEvent.branch) 
            } 
        } 
        on ("success").to "addPO" 
    } 

    addPO { 
        on("add") { 
            log.debug("addPO") 
            // Initialize flow objects 
            flow.poInfo = new PoInfo(params) 
            if (flow.receivingEvent == null) { 
                flow.receivingEvent = new ReceivingEvent() 
            } 

            // validate and populate poInfo object 
            boolean objectIsValid = flow.poInfo.validateAndPopulate() 
            if(!objectIsValid) { 
                if(!flow.poInfo.hasErrors()) { 
                    flash.warning = 'poInfo.poNumber.unknown' 
                } 
                return error() 
            } 
            // add poInfo object to receivingEvent for additional processing/validation 
            String errorMessage = flow.receivingEvent.addPoInfo(flow.poInfo) 

            if(null != errorMessage) { 
                flash.warning = errorMessage 
                return error() 
            } else { 
                flow.poInfo = null 
            } 
        }.to("addPO") 


这是我的集成测试:

class ReceivingEventCreationFlowTests extends WebFlowTestCase{ 

ReceivingEventController receivingEventController = new ReceivingEventController() 

void testInitializeFlow() { 
    startFlow() 
    assertCurrentStateEquals "addPO" 
} 

void testAddPoInfoMissingPiecesPallets() { 
    println("Hola mundo") 
    startFlow() 
    assertCurrentStateEquals "addPO" 

    receivingEventController.params.poNumber = '63055024UI1063' 
    receivingEventController.params.pro = '3' 
    println "flow scope: " + getFlowScope().getClass() 
    println ("Hola again") 
    signalEvent('add') 
    assertTrue getFlowScope().poInfo.hasErrors() 
    assertCurrentStateEquals "addPO" 
} 

@Override 
public Object getFlow() { 
    receivingEventController.createFlow 
} 

String getFlowId() { "create" } 
} 

有人知道我错过了什么吗?或者webFlow 2.0.0和grails 2.0.3是否存在任何已知的集成测试问题

我遵循《Grails在行动》一书中的指导原则,第9.4章:测试WebFlows。。。然而,我不断地得到上面的错误

提前感谢,


豪尔赫·瓦斯奎兹(Jorge Vasquez)

圣杯行动(Grails in Action)是一本非常好的书,但有些陈旧。我建议您使用单元测试而不是集成测试。文档几乎不存在,但您可以在grails源代码中看到一个很好的示例:

您可以看到包含输入、输出、子流等的WebFlow(输入和输出比GIA书籍更新)


在Roeche使用对话范围的示例中,您可以改为使用流范围。

链接当前已关闭。是的,我的新建议:不要使用webflow。它是有缺陷的,没有文档记录。看起来这可能是当前的链接: