单元测试嵌套子流(子流的子流)

发布于 2024-09-03 07:03:01 字数 444 浏览 5 评论 0原文

我正在尝试为一个流程编写单元测试,该流程有一个子流程,该流程本身还有另一个子流程。

我使用注册第一个流程 FlowDefinitionResource getResource(FlowDefinitionResourceFactory resourceFactory)

然后,我在测试执行期间在 FlowDefinitionRegistry 中注册子流定义,然后再转换到它们。

转换到“第一级”子流程没问题。转换到当前子流的子流的结果 - NoSuchFlowDefinitionException

问题是子流定义似乎都附加到测试的主流,并且在另一个子流中找不到子流。

有没有办法将子流定义附加到测试中的另一个子流,从而扩展 AbstractXmlFlowExecutionTests

I'm trying to write unit test for a flow, which has subflow, which, itself, has another subflow.

I register first flow using
FlowDefinitionResource getResource(FlowDefinitionResourceFactory resourceFactory).

Then I register subflow definitions during test execution in FlowDefinitionRegistry before transitioning to them.

Transitioning to "first level" subflow goes ok. The result of transitioning to subflow of current subflow - NoSuchFlowDefinitionException.

The problem is that subflow definitions are all seem attached to the primary flow of the test and subflow can't be found within another subflow.

Is there any way to attach subflow definition to another subflow in tests, which extend AbstractXmlFlowExecutionTests?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

梦萦几度 2024-09-10 07:03:01

您应该单独测试每个流程。因此,第一次测试顶部流程并模拟第一个子流程,然后仅测试第一个子流程并模拟第二个子流程,依此类推...

http://static.springsource.org/spring-webflow/docs/2.3.x/reference/html/ch15s07.html

You should test every flow alone. So first time test top flow and mock first subflow, then test only first subflow and mock second one and so on...

http://static.springsource.org/spring-webflow/docs/2.3.x/reference/html/ch15s07.html

嘿嘿嘿 2024-09-10 07:03:01

我认为这是可能的,但要正确执行有点复杂。

看一下这个帖子:用子流测试流不起作用。最底线的答案似乎是:重写 configureFlowBuilderContext(MockFlowBuilderContext builderContext) 虚拟方法并在其中注册您的模拟。

这个 Spring 框架的 JIRA 案例涉及到这个问题,也表明这是可能的,但很复杂。

I think this is possible, but a little convoluted to get right.

Have a look at this thread: Testing a flow with subflow doesn't work. The bottom line answer appears to be: override the configureFlowBuilderContext(MockFlowBuilderContext builderContext) virtual method and register your mock in there.

This JIRA case for the Spring framework touches on this issue and also suggests it's possible but convoluted.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文