【问题标题】:How to assert in a unit test that Spring Webflow exited through the specific end state?如何在单元测试中断言 Spring Webflow 通过特定的结束状态退出?
【发布时间】:2013-09-26 03:10:16
【问题描述】:

我正在研究对 Spring Webflow 进行单元测试的方法。被测网络流有多个结束状态。有没有办法确定工作流是通过哪些最终状态退出的?

我当前的代码是:

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

我尝试断言当前状态等于相关结束状态的 id,但断言失败,因为工作流已经终止。

有什么建议吗?

【问题讨论】:

    标签: java spring unit-testing spring-webflow spring-webflow-2


    【解决方案1】:

    您可以使用assertFlowExecutionOutcomeEquals 来检查,您的测试方法应该是这样的:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-02-04
      • 2014-10-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多