Unit Tests Overview (Simple Flow)

Last Updated: 07/19/2016 Introduced in Verision: 3.5

In Decisions 3.5 Unit Test utility is separated from the Debugger. User is able to Test Flow/Rule and see if it is executing correctly in the Debugger or create Unit Tests to apply custom Rules to the places in the Flow/Rule that need to be tested.

Example:

This document overviews main features of Unit Test utility on the simple Flow example.

We start in the Designer Folder by clicking Create Flow on the Folder Actions Panel.

createFlow

In the resulting window we Name the Flow and click Create to proceed to the Flow Designer.

nameFlow

In the Flow Designer we select Start step on the workspace and add simple String Input into our Flow.

addFlowInput

Then, we connect Start step to the End step in the Flow. With End Step selected we add simple String Output to our Flow.

addFlowOut

For the Output that we just created we use Select Value Mapping type and select Input Value that we created in the Start Step.

mappOutput

As a result, we have a simple Flow with simple String Input, one Outcome Path, and simple String Output. Mention, on the Top Panel of the Flow Designer there is no Debug Flow option. Instead of Debug Flow we have Test Flow and Unit Test. We click Test Flow

testFlow

Mention, that Flow Designer do not ask us to create a Unit Test because our Flow has a variable input unlike Decisions 3.2 and older versions. Debugger opens and asks us to provide a Value for the Flow Input. Then, we click Run.

inputDebug

The Flow executes in the Debugger just like in previous versions of Decisions.

debugged

Back in the Flow Designer we click Unit Test on the Top Panel of the Flow Designer.

unitTestFlow

Because there are no Unit Tests created for this Flow, Wizard asks us to create one. In this example we are going to create Unit Tests to test Flow Input, Flow Output, and Flow Outcome Path. We Name first Unit Test and define Flow Input. For each Unit Test we need to write a Test Result Evaluation Rule. This Rule will have a logic to test if our Flow executes as we designed at particular points of execution. We click Edit Test Result Evaluation Rule.

createFirstTestEditRule

Rule Designer opens. Note: if our Rule returns true, Unit Test passes. We click Add New Rule Step.

addNewRuleStep

Mention, for this simple Flow Unit Test Rule we have some additional input data:

  • Input (to test Flow Input)
  • Outcome_PathName (to test if our Flow was executed on particular outcome)
  • Outcome_Done_Output (to test Flow Output value on Outcome Path Done)

We select Input for this Unit Test.

ruleInputs

 

We expect this Unit Test to pass so we write a Rule where Input equals the value that we provided as Flow Input for this Unit Test. When finished we can save the Rule and close Rule Designer.

completeFirstRule

Back in the Flow Unit Tests wizard we click Save.

saveFirstUnitTest

Then, in Flow Unit Tests window we can see our first Unit Test saved. We can click Create New to add more Unit Tests for this Flow. Again, we provide Test Name, Input, and click Edit Test Result Evaluation Rule.

createSecondUnitTest

We build second Rule to test Flow Input and return False.

secondRuleCompleted

Next, we add another Unit Test to check if Outcome_PathName is done. This Unit Test checks if our Flow was executed on the Outcome Path that we expected.

passNameRule

Then, we add another Unit Test with the Rule that checks Outcome_PathName and returns False.

outcomeFailRule

Finally, we create two Unit Tests for the Flow Outcome. First Test should pass. In the Rule for the Unit Test we check if the Outcome_Done_Output equals Input.

outPassRule

Lastly, we add a Unit Test to check Outcome_Done_Output and return False.

outputFailRule

As a result, we have six Unit Tests for our simple Flow… In the Flow Unit Tests window we can click Run All to run all Unit Tests.

runAll

… and they execute as we expected.

testsRan

 

 

Additional Resources