Views:

Overview

Follow the steps in this article to set up a Test to check that an automatically triggered Flow is functioning as expected.

Prerequisites

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

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 Automated Flow
    • 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: A new Calculation record is 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 record is created
    • Select cell B8, for the Then step
      • Enter the text: Flow logic is executed and saves the calculated value into the [Automated Flow Result] field
  • Click Save

Arrange

We need to create records to which the Flow will execute on. We use the Test Data set up previously for this purpose.

  • Select the Source tab
    • Expand the Test Data node
    • Expand Test Data - Calculator 
    • Click on Calculation - the default Arrange sheet is replaced with Arrange-Calculation with Test Data pre-populated
  • Click Save

Act

The Flow will execute automatically so we do not need to specify any actions for the Act sheet.

Assert

Once the test records have been created we need to check that the calculated values are what we expect.

  • Select the Assert sheet
  • Select cell B4
  • Select the Source tab
  • Expand the Arrange node
  • Expand Arrange-Calculation (the four rows of data are shown as nodes)
  • Expand Arrange-Calculation-Row-0004
  • Click on Automated Flow Result
    • {Arrange-Calculation-Row-0004-Automated Flow Result} is added to cell B4. When the Test executes it will find this value from the record created in the Arrange step.
  • Select cell C4
    • Enter the number 15 as the expected value of our calculation
  • Select cell D4
    • Enter Add as the Step Message. This will be displayed in the Test Results so that you can quickly identify what was being tested.
  • Select cell B4, and position the cursor over the bottom right corner of the cell to show the Excel-style fill handle
    • Drag down 3 rows to cell B7. You will notice that the row number reference is automatically updated (Note: you could manually add each reference field from the Local Data nodes but copying the cells down is much quicker)
  • Click into cells A5, A6 and A7 to select the AssertAreEqual Assert Type
  • Select cell C5
    • Enter the number 5 as the expected value of our calculation
  • Select cell D5
    • Enter Subtract as the Step Message
  • Select cell C6
    • Enter the number 50 as the expected value of our calculation
  • Select cell D6
    • Enter Multiply as the Step Message
  • Select cell C7
    • Enter the number as the expected value of our calculation
  • Select cell D7
    • Enter Divide as the Step Message
  • Click Save

Run the Test

The Test is now ready to be run. For this exercise we will run the Test manually - in a later exercise we'll show you how to run the Test automatically. 

  • 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 flow processes to complete and the Test Results records to be created
  • On the Source tab, click the refresh button in the top right of the tab, then expand Test Run Results
    • You will see a node with with the time of your test and the Pass/Fail results (you should have 4 passes!), expand this node
    • Expand Assert
    • Expand Row-0004
    • Expand Add
      • 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.