簡體   English   中英

如何在單元測試中斷言Spring Webflow是否通過特定的最終狀態退出?

[英]How to assert in a unit test that Spring Webflow exited through the specific end state?

我正在研究Spring Webflow的單元測試方法。 正在測試的Web流具有多個結束狀態。 有沒有辦法確定,通過哪些最終狀態工作流程退出?

我目前的代碼是:

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

我試圖斷言當前狀態等於所討論的最終狀態的id,但斷言失敗,因為工作流已經終止。

有什么建議?

您可以使用assertFlowExecutionOutcomeEquals來檢查,您的測試方法應該是這樣的:

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM