2012-08-16 1 views
0

Grails 2.0.3 및 webFlow 2.0.0을 사용하고 있습니다.webFlow 2.0.0 용 Grails 통합 테스트를 실행할 수 없습니다.

내 컨트롤러에 잘 작동하는 WebFlow 정의가 있지만 향후 유지 관리를 위해 통합 테스트를 추가하고 싶습니다. 이것은 내가 테스트하려고 내 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.code[email protected]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 

입니다 :

나는 컨트롤러 시도 유량 범위에 어떤 값을 추가 할 때마다 내 테스트에서 다음과 같은 예외를 얻고있다 :

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 테스트 ... 가이드의 지침을 따르고 있지만 위의 오류가 계속 발생합니다. 사전에

감사, 액션

호르헤 바스케스

답변

0

Grails는 매우 좋은 책이지만 오래된입니다. 나는 당신이 통합 테스트 대신 단위 테스트를 사용하기를 권장합니다. 문서는 거의 inexistent입니다하지만 당신은 Grails의 소스 코드의 좋은 예를 볼 수 있습니다

WebFlow unit test code

당신은 입력, 출력, 서브 플로우 등으로 webflows을 볼 수 있습니다을

(입력과 출력이 최신 인 GIA 책이)

예에서 Roeche는 대화 범위를 사용하지만 대신 흐름 범위를 사용할 수 있습니다.

+0

현재 링크가 작동하지 않습니다. – Daneo

+0

그래, 내 새로운 추천 : 웹 흐름을 사용하지 마십시오. 그것은 버그가 있고 문서화되지 않았습니다. –

+0

현재 링크 일 수 있습니다 : https://github.com/grails/grails-core/blob/9560f8275abb76e3ba0afe94967ee196768d0af6/grails-plugin-testing/src/test/groovy/grails/test/mixin/WebFlowUnitTestMixinTests.groovy –

관련 문제