Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unit testing nested subflows (subflows of subflows)

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?

like image 758
tiurin Avatar asked May 31 '10 19:05

tiurin


2 Answers

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

like image 80
none_ Avatar answered Nov 07 '22 05:11

none_


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.

like image 41
Judah Gabriel Himango Avatar answered Nov 07 '22 04:11

Judah Gabriel Himango