开发者

Unit testing nested subflows (subflows of subflows)

开发者 https://www.devze.com 2023-01-01 22:41 出处:网络
I\'m trying to write unit test for a flow, which开发者_如何学C has subflow, which, itself, has another subflow.

I'm trying to write unit test for a flow, which开发者_如何学C 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?


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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消