문제

I'm researching the means of unit testing a Spring Webflow. The webflow under test has multiple end states. Is there a way to determine, through which of those end states did the workflow exit?

My current code is:

    @Test
    public void flow_ends_on_cancel_from_start_state() {
        startFlow(context);
        context.setEventId("cancel");
        resumeFlow(context);
        assertFlowExecutionEnded();
    }

I tried asserting for the current state being equal to the id of the end state in question, but the assertion was failing because the workflow had already terminated.

Any advice?

도움이 되었습니까?

해결책

You can use assertFlowExecutionOutcomeEquals to check that, your test method should be something like this:

@Test
public void flow_ends_on_cancel_from_start_state() {
    startFlow(context);
    context.setEventId("cancel");
    resumeFlow(context);
    assertFlowExecutionEnded();
    assertFlowExecutionOutcomeEquals("endStateId");
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top