Views:

Overview

Follow the steps in this article to set up a Test to check that multiple processes (workflows, Flow, business rules, North52 BPA formula) are functioning as expected.

Prerequisites

For this article you will need to have installed and configured the North52 Calculator Demo solution.

Create the Test

Initial Set up

  • Open the North52 Decision Suite app
  • Navigate to TestShield > Tests
  • Click New
  • On the Register tab
    • For Test Plan enter Demo Calculator (or select from the list of existing Test Plans)
    • For Test Suite enter Calculations (or select from the list of existing Test Suites)
    • For Test Case enter All Calculations
    • For Test Type select Process Shield
    • For Sync or Async select Async
    • For A(this means the test will create the test records then allow 1 minute for the Flow process to execute, then it will assess the Asserts)
  • Click Save

Assemble

On the Assemble sheet we describe the specific scenario of a feature that will be tested and outline the steps of the test using Gherkin-style syntax.

  • On the Assemble sheet, edit cell B1 to describe the Feature being tested. Enter the text: Demo Calculator
  • Double-click cell B2
    • For the Scenario, describe what is being tested - we like to use a User Story. Enter the text:
      As a User
      I want to calculate two numbers using different operators
      So that I get the right results without having to use a separate calculator
  • The next steps describe the steps of the test:
    • Select cell B6, for the Given step
      • Enter the text: Four Calculation records are created as defined in the Arrange-Calculation sheet (we'll add the Arrange-Calculation sheet after we complete the Assemble sheet)
    • Select cell B7, for the When step
      • Enter the text: the Calculation records are created
    • Select cell A8 and position the cursor over the bottom right corner of the cell to show the fill handle
      • Drag down 5 rows to cell A13
    • Select cell B8, copy and paste the following in cells B8-B13:
      • North52 BPA Formula logic is executed and saves the calculated value into the [North52 BPA Result] field
      • Flow logic is executed and saves the calculated value into the [Automated Flow Result] field
      • Business Rule logic is executed and saves the calculated value into the [Business Rule Result] field
      • Flow logic is executed and saves the calculated value into the [Flow HTTP Trigger Result] field
      • Background Workflow logic is executed and saves the calculated value into the [Workflow Result (Workflow)] field
      • Real-time Workflow logic is executed and saves the calculated value into the [Workflow Result (Real Time)] field
  • Click Save

Arrange

To set up the data for this test we are going to manually create Calculation records, essentially 'recording' our desired outcome using each Operator type (Add, Subtract, Multiply, Divide). These records will then form the basis for the Arrange and Assert steps.

Create the Calculation Records

  • Open the North52 Calculator Demo app
  • From the left sidebar menu select Calculations
  • Delete all the calculation records that have been created as part of previous test runs
  • Click New
    • Enter 10 in the Value One field
    • Enter 5 in the Value Two field
    • Select Add for the Operator
    • Enter Add for the Name
    • Click Save
    • Click the Calculate Using Flow HTTP trigger button
    • Wait 30 seconds and refresh the records to check all Results fields have been populated
  • Repeat this for 3 additional records, changing the Operator and Name to match the operator so that you have four records named Add, Subtract, Multiply and Divide.
    • Note that for the Divide Operator there will not be results populated for the Workflow (background and real-time) as it is not possible to do division as part of an out of the box workflow
  • The 'recording' is now complete and we are ready to use these records to continue building our test

Complete the Arrange sheet

  • Go back to your Test that you created in the previous section
  • Select the Arrange sheet
  • Select the Explore tab
    • Expand the Explore System Data node
    • Select the Calculation entity from the picklist
      • There should be four records shown - Add, Subtract, Multiply and Divide
    • Expand the Add record
    • Expand Attributes
      • Check the Operator, Value One and Value Two fields
    • Scroll back up, and close the Attributes node
    • Check the Add, Subtract, Multiply and Divide nodes
    • Click the lightning bolt button to add the selected data to the Arrange sheet:

  • Click Save

Act

The Act Sheet allows you to execute any functions after the records in the Arrange sheet(s) have been created. For this test we need to trigger a Flow via an HTTP request. 

  • Select the Act sheet
  • Select cell A4
    • Enter the text Flow HTTP Trigger - Add
  • Select cell B4
    • Expand the editor for the cell by clicking the + in the top right of the sheet
    • Select the Functions tab and search for flow
    • Click on the ExecuteMSFlowRequest function to add the function and placeholder parameter to the formula editor
    • Delete the 'url' placeholder text including the quotes
    • Select the Source tab
      • Expand xCache
      • Expand Calculator
      • Click on Calculator_FlowTriggerUrl (you will have edited this xCache record as part of the installation and configuration of the Calculator Demo solution)
    • Delete the 'body' placeholder text including the quotes and replace with the following (Parameters need to be passed to the Flow in JSON format):
        CreateJObject( 
          CreateJProperty('value1', FindRecordsValue(GetVar('Arrange-Calculation-Row-0004'), 'north52_valueone')),
          CreateJProperty('value2', FindRecordsValue(GetVar('Arrange-Calculation-Row-0004'), 'north52_valuetwo')),
          CreateJProperty('operation', FindRecordsValue(GetVar('Arrange-Calculation-Row-0004'), 'north52_operatorname')),
          CreateJProperty('recordId', FindRecordsValue(GetVar('Arrange-Calculation-Row-0004'), 'north52_calculationid'))
        )
    • The completed formula should look like this:
    • Close the cell editor
  • Select cell A5
    • Enter the text Flow HTTP Trigger - Subtract
  • Select cell B5
    • Repeat the steps for cell B4, replacing Arrange-Calculation-Row-0004 with Arrange-Calculation-Row-0005
  • Select cell A6
    • Enter the text Flow HTTP Trigger - Multiply
  • Select cell B6
    • Repeat the steps for cell B4, replacing Arrange-Calculation-Row-0004 with Arrange-Calculation-Row-0006
  • Select cell A7
    • Enter the text Flow HTTP Trigger - Divide
  • Select cell B7
    • Repeat the steps for cell B4, replacing Arrange-Calculation-Row-0004 with Arrange-Calculation-Row-0007
  • The completed Act sheet will look like this:

Assert

Once the records have been created we need to check that the calculated values are what we expect. For this test we are introducing a different method to define the Asserts which is based on a existing record - for a lot of tests this will be the fastest way to define your asserts.

  • Select the Assert sheet
  • Select the Explore tab
    • Expand the Explore System Data node
    • Select the Calculation entity from the picklist
      • There should be four records shown - Add, Subtract, Multiply and Divide
    • Expand the Add record
    • Expand Attributes
      • Check the following fields:
        • Automated Flow Result
        • Business Rule Result
        • Flow HTTP Trigger Result
        • North52 BPA Result
        • Workflow Result (Background)
        • Workflow Result (Realtime)
    • Scroll back up, and close the Attributes node
    • Check the Add, Subtract, Multiply and Divide nodes
    • Click the lightning bolt button to add the selected data to the Arrange sheet
  • The final step is to bind the asserts to the records created in the Arrange sheet
    • Select the Source tab
      • Expand Arrange
      • Expand Arrange-Calculation
    • Select cell B4
      • Select Arrange-Calculation-Row-0004
    • Select cell B5
      • Select Arrange-Calculation-Row-0005
    • ​​​​​​​Select cell B6
      • Select Arrange-Calculation-Row-0006
    • ​​​​​​​Select cell B7
      • Select Arrange-Calculation-Row-0007
  • Your Arrange sheet should now look like:

  • Click Save

Run the Test

The Test is now ready to be run. For this exercise we will run the Test manually.

  • Click the Execute Test button - represented by the lightning button in the top right of the Test editor canvas
  • Click the Execute button on the fly-out pane
  • After a few seconds the Test records will be created (a message Result: Operation Completed will be shown)
  • Wait one minute for the asynchronous workflow processes to complete and the Test Results records to be created
  • From the Source tab, expand Test Run Results
    • You will see a node with the time of your test and the Pass/Fail results (you should have 26 passes!), expand this node
    • Expand Assert-Calculation
    • Expand Row-0004
    • Expand D - north52_businessruleresult
      • You will see the Actual and Expected values​, and the Assert Type:

​​​​​​​​​​​​​​​​​​​​​

You could experiment to get a failure by changing the values in the Expected Value column and running the test again.