Views:

Overview

Follow the steps in this article to set up a Test to ensure that a Global Action is returning the correct parameter values. We use a simple global Action which has been set up to return two hard coded parameters - a decimal number and a string.

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 Training
    • For Test Suite enter TestShield
    • For Test Case enter Global Action Response
    • For Test Type select Process Shield
    • For Sync or Async select Sync
  • 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: Global Actions
  • Double-click cell B2
    • For the Scenario, describe what is being tested:
      • Enter the text: Call the 'TestShield Training Sample Global Action' to return the test parameter values
  • The next steps describe the steps of the test:
    • Select cell B6, for the Given step
      • Enter the text: That the TestShield Training Sample Global Action is called
    • Select cell B7, for the When step
      • Enter the text: the Action is executed by the system
    • Select cell B8, for the Then step
      • Enter the text: Two parameters are returned, TheNumber10 and HelloWorld, with the values '10' and 'Hello World' respectively
  • Click Save

Arrange

There is no test data to set up for this test as we are just calling the global Action without any input values.

Act

We need to make a call to the global Action and use the Act sheet for this purpose. We will use North52 functions to execute the Action and retrieve the output parameters.

  • Select the Act sheet
  • Select cell A4
    • Enter the text: Execute Action The Number 10
  • Select cell B4
    • Expand the cell editor by clicking on the + icon in the top right of the Act sheet
    • Select the Functions tab
    • Search for getaction
    • Click on the GetActionOutputParameter function to add it to the cell
      • Replace the placeholder text outputparametername with TheNumber10 - this is one of the output parameters of the Global Action
      • Remove the placeholder text 'defaultname' including the preceding comma
      • Remove the placeholder text 'executeaction' leaving the cursor in its position
    • Enter executeaction in the Functions search 
    • Shift-click on the ExecuteAction function to open the function wizard
      • Action Name parameter:
        • Search for test and select north52_TestShieldTrainingSampleGlobalAction
      • Leave the Entity Name and Record ID parameters blank
      • Click Generate
    • The formula in the cell should now look like this:
      GetActionOutputParameter(ExecuteAction('north52_TestShieldTrainingSampleGlobalAction'), 'TheNumber10')
    •  Close the cell editor by clicking the X in the top right of the sheet
  • Select cell A5
    • Enter the text: Execute Action Hello World
  • Select cell B4, and position the cursor over the bottom right corner of the cell to show the fill handle
    • Drag down 1 row to cell B5
    • Replace the parameter TheNumber10 text with HelloWorld - this is the other output parameter of the Global Action
  • Click Save

Assert

Once the Action has been executed we need to check that the returned values are what we expect.

  • Select the Assert sheet
  • Select cell A4
    • AssertAreEqual is automatically added to the Assert Type as the default assert type
  • Select cell B4
    • Select the Source tab
    • Expand the Act node (if nothing is displayed after expanding the node, click the refresh icon in the top right corner of the Source tab)
    • Click on Execute Action The Number 10
      • {Execute Action The Number 10} is added to cell B4 
  • Select cell C4
    • Enter the number 10 as the expected value of the parameter being returned
  • Select cell D4
    • Enter The Number 10 as the Step Message. This will be displayed in the Test Results so that you can quickly identify what was being tested.
  • Select cell A5
    • AssertAreEqual is automatically added to the Assert Type as the default assert type
  • Select cell B5
    • From under the Act node in the Source tab, click on Execute Action Hello World
      • {Execute Action Hello World} is added to cell B5
  • Select cell C5
    • Enter 'Hello World' including quotes as the expected string value of the parameter being returned
  • Select cell D5
    • Enter Hello World as the Step Message. This will be displayed in the Test Results so that you can quickly identify what was being tested.
  • 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
  • Wait a few seconds for the Test records and the Test Results records to be created (a message Result: Operation Completed will be shown)
  • From the Source tab, expand Test Run Results
    • You will see a node with with the time of your test and the Pass/Fail results (you should have 2 passes!), expand this node
    • Expand Assert
    • Expand Row-0004
    • Expand The Number 10
      • 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.