Вопрос

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