单元测试嵌套子流(子流的子流)
我正在尝试为一个流程编写单元测试,该流程有一个子流程,该流程本身还有另一个子流程。
我使用注册第一个流程 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 usingFlowDefinitionResource 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您应该单独测试每个流程。因此,第一次测试顶部流程并模拟第一个子流程,然后仅测试第一个子流程并模拟第二个子流程,依此类推...
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
我认为这是可能的,但要正确执行有点复杂。
看一下这个帖子:用子流测试流不起作用。最底线的答案似乎是:重写 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.