Unit testing nested subflows (subflows of subflows)
Asked Answered
P

2

7

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?

Pedant answered 31/5, 2010 at 19:8 Comment(1)
Does anybody know how to do this ? I'd very much like to find out as I'm having the same problem.Willemstad
Y
1

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

Yuu answered 4/10, 2012 at 12:44 Comment(1)
Two years late, but still could be useful for someone.:)Yuu
D
1

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.

Drome answered 8/11, 2010 at 20:2 Comment(0)
Y
1

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

Yuu answered 4/10, 2012 at 12:44 Comment(1)
Two years late, but still could be useful for someone.:)Yuu

© 2022 - 2024 — McMap. All rights reserved.