Step/Data Simulation For Unit Tests
  • 15 Sep 2021
  • 1 Minute to read
  • Dark
    Light

Step/Data Simulation For Unit Tests

  • Dark
    Light

Article Summary

Overview

As of Decisions v.7.7+, users are provided the option to add unique mock data/Simulation paths to one or more Unit Tests. This allows the ability to run multiple different Unit Tests while testing different possible outcomes/Input Data.

Example

About Example
The following example involves utilizing a Flow that contains two previously configured Unit Tests. For information on how to configure Unit Tests in Decisions see:
To enable this feature:
  1.  From a Flow that contains two configured Unit Tests, select the desired step for Simulation
  2. From the step's Properties tab, navigate to TESTING SIMULATION > Use Simulation Behavior, and enable the InUnitTests option. 
  3. Under Simulation Selected Path, select FromFlow, then click the EDIT [FLOW NAME] button. 
  4. In the resulting Flow Designer, select the SETUP INPUT DATA button. In the Data Definitions window, define the desired mock data by providing a NAME and selecting the desired TYPE (this example uses Boolean) from the dropdown. Save and close the Input Data window. 
  5. Design a Flow that Outputs an Outcome path to the End step (or End steps if multiple are involved). Save and close the Flow. 


  6. Back in the Primary Flow, EDIT the Flow's Input Data and define Flow Input Data that matches the previously created Input from the Simulation Path Flow
  7. Select the step that has the Simulation Behavior enabled; under TESTING AND SIMULATION > Simulation Data, map the newly defined Input Data to the Simulation Data. 
  8. Save the Flow, then click the Debug link on the top Action bar. 
  9. From the Debugger, If needed, EDIT the Unit Test Rule via the respective button under [UNIT TEST DATA] to match the Input Data.
  10. Uunder UNIT TESTS, select a Unit Test; Under DATA SOURCE FOR UNIT TEST RULE, select Input Data - Constant
    Alternate Data Source
    If desired the From Flow option (see previous Alternate Example A: Flow As Data Source (v.7.7+) section on Unit Testing (Advanced) for detail) may be used as the Unit Test's Data Source.

  11. Under INPUT DATA, define the Input as desired, then click Save. 
  12. Navigate to the other Unit Test and define the Input Data with a different value, then click Save. 
  13. Click Run All to test each Unit Test and their unique mock data/Simulation paths. 
    About Test Results 
    Upon running the Unit Tests, if properly configured, the expected amount of Successful and Failed results should occur. 




Was this article helpful?