Views:

Overview

This article shows how to create a Test to provide the necessary coverage for a credit card eligibility scenario enforced with a North52 Formula. It covers both positive and negative tests, boundary tests and how to set up the corresponding Test Runner and DevOps Pipeline to automate the Test. 

The Formula

The Credit Card eligibility Formula is set up on the Contact table like this:

Credit Card Eligibility Decision Table Formula

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 TestShield Demo (or select from the list of existing Test Plans)
    • For Test Suite enter Process Shield (or select from the list of existing Test Suites)
    • For Test Case enter Platinum Credit Card
    • 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: Platinum Credit Card
  • 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 provide Annual Income, Credit Score and Total Assets amounts for a Contact
      So that I can assess whether the Contact is eligible for a Platinum Credit Card
  • The next steps describe the steps of the test:
    • Select cell B6, for the Given step
      • Enter the text: A new Contact record is created as defined in the Arrange-Contact sheet (we'll add the Arrange-Contact sheet after we complete the Assemble sheet)
    • Select cell B7, for the When step
      • Enter the text: the Contact record is created
    • Select cell B8, for the Then step
      • Enter the text: North52 BPA Formula logic is executed and updates the Credit Card Type value
  • Click Save

    TestShield Assemble Sheet

Arrange

We need to Contact create records to which the North52 BPA Formula will execute on and the tests will be asserted against. 

First, we create a Contact in the system with minimum data required to ensure the Platinum Credit Card Eligibility Formula returns a positive result (Annual Income, Credit Score and Total Assets of Applicant fields completed). 

Sample Contact for Credit Card Eligibility

Then we use this Contact and information as the basis for setting up the data in the Arrange sheet. Once this contact is created:

  • Select the Arrange-Contact sheet
    • Select the Explore Tab
    • Expand Explore System Data
    • Select Contact from the dropdown
    • Search for your Contact, in our case North52 Demo
    • Expand the Contact node
    • Expand the Attributes node
      • Select the Annual Income, Credit Score and Total Assets of Applicant field checkboxes
    • Select the Contact checkbox
    • Click the Lightning Bolt icon to add the details to the sheet
    • Add a Comment column in column F
  • Click Save

We need to create records (new lines) for each scenario to be tested - positive and negative tests for each line in the Formula Decision table as well as boundary tests for the range conditions.  You can manually do this or to speed things up use an AI service like ChatGPT to help determine the tests. For our test we need:

Annual IncomeCredit ScoreTotal Assets of ApplicantNotes
50000189250000Positive
50000188250000Negative
50000181750000Positive
50000180750000Negative
500001731500000Positive
500001721500000Negative
125000165250000Positive
125000164250000Negative
125000160750000Positive
125000159750000Negative
1250001521500000Positive
1250001511500000Negative
175000146250000Positive
175000145250000Negative
175000135750000Positive
175000134750000Negative
1750001321500000Positive
1750001311500000Negative
250000125250000Positive
250000124250000Negative
250000121750000Positive
250000120750000Negative
2500001131500000Positive
2500001121500000Negative
99999189499999Income boundary at 100000: Just below (triggers Rule 1)
99999188499999Income boundary at 100000: Just below, credit too low for Rule 1
100000165499999Income boundary at 100000: On boundary (triggers Rule 4)
100000164499999Income boundary at 100000: On boundary, credit too low for Rule 4
50000189499999Assets boundary at 500000 in low income: Just below (Rule 1)
50000188499999Assets boundary at 500000 in low income: Just below, credit boundary
50000181500000Assets boundary at 500000 in low income: On boundary (triggers Rule 2, lower credit ok)
50000180500000Assets boundary at 500000 in low income: On boundary for Rule 2
50000181999999Assets boundary at 1000000 in low income: Just below (Rule 2)
500001811000000Assets boundary at 1000000 in low income: On boundary (still Rule 2)
500001731000001Assets boundary at 1000000 in low income: Just above (triggers Rule 3)
500001721000001Assets boundary at 1000000 in low income: Just above, credit too low for Rule 3
149999165499999Income boundary at 150000: Just below (triggers Rule 4 example)
150000165499999Income boundary at 150000: On boundary, qualifies under Group 2 (Rule 4)
150000146499999Income boundary at 150000: On boundary, low credit, falls to Group 3 (Rule 7)
150000145499999Income boundary at 150000: On boundary, credit too low for both
199999146499999Income boundary at 200000: Just below (triggers Rule 7 example)
200000146499999Income boundary at 200000: On boundary (still Group 3, Rule 7)
200001125499999Income boundary at 200000: Just above (triggers Rule 10)
200001124499999Income boundary at 200000: Just above, credit too low
  • Add these values to the Arrange-Contact Sheet in rows 4 to 47, columns C to F
  • Select cells A4 and B4, and position the cursor over the bottom right corner of the cell to show the fill handle
    • Drag down rows to cell B47. You will notice that the row number reference is automatically updated in column A
    • Note: column B is copied down with the same ID, however when new records are created new ID is generated
  • Click Save

Act

The North52 BPA Formula will execute automatically in real-time so we do not need to specify any actions for the Act sheet.

Assert

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

  • Select the Assert sheet
  • Select cell A1
    • Select the Explore tab and select the Contact record as was done in the step above
    • In the Attributes node also check the Credit Card Type field
    • Select the Contact checkbox
    • Click the Lightning Bolt icon to add the details to the sheet
  • Move the column Credit Card Type to the end:
    • Select column D (Credit Card Type) by clicking on the column header
      • Right-click and select Cells > Cut
      • Select column G
      • Right-click and select Cells > Paste
  • Delete the empty column D:
    • Select column D
      • Right-click and select Delete > Delete Column
  • Add another column for Credit Card Type:
    • Select column F (Credit Card Type)
      • Right-click and select Cells > Copy
      • Select column G
      • Right-click and select Cells > Paste
    • Change the Assert to AssertAreNotEqual
      • Select cell G1
      • Press the F2 key
      • Select AssertAreNotEqual from the dropdown
  • Insert a Comment column in column H
  • Select cell B4
    • Expand the Arrange node
    • Expand Arrange-Contact
    • Click on Arrange-Calculation-Row-0004
  • Select cell A4, and position the cursor over the bottom right corner of the cell to show the fill handle
    • Drag down to cell A47.
  • Select cell B4, and position the cursor over the bottom right corner of the cell to show the fill handle
    • Drag down to cell B47. You will notice that the row number reference is automatically updated

We need to complete the asserts to match the Positive, Negative, and Boundary test data set up previously. 

Annual IncomeCredit ScoreTotal Assets of ApplicantCredit Card TypeCredit Card TypeNotes
50000189250000{Platinum} Positive
50000188250000 {Platinum}Negative
50000181750000{Platinum} Positive
50000180750000 {Platinum}Negative
500001731500000{Platinum} Positive
500001721500000 {Platinum}Negative
125000165250000{Platinum} Positive
125000164250000 {Platinum}Negative
125000160750000{Platinum} Positive
125000159750000 {Platinum}Negative
1250001521500000{Platinum} Positive
1250001511500000 {Platinum}Negative
175000146250000{Platinum} Positive
175000145250000 {Platinum}Negative
175000135750000{Platinum} Positive
175000134750000 {Platinum}Negative
1750001321500000{Platinum} Positive
1750001311500000 {Platinum}Negative
250000125250000{Platinum} Positive
250000124250000 {Platinum}Negative
250000121750000{Platinum} Positive
250000120750000 {Platinum}Negative
2500001131500000{Platinum} Positive
2500001121500000 {Platinum}Negative
99999189499999{Platinum} Income boundary at 100000: Just below (triggers Rule 1)
99999188499999 {Platinum}Income boundary at 100000: Just below, credit too low for Rule 1
100000165499999{Platinum} Income boundary at 100000: On boundary (triggers Rule 4)
100000164499999 {Platinum}Income boundary at 100000: On boundary, credit too low for Rule 4
50000189499999{Platinum} Assets boundary at 500000 in low income: Just below (Rule 1)
50000188499999 {Platinum}Assets boundary at 500000 in low income: Just below, credit boundary
50000181500000{Platinum} Assets boundary at 500000 in low income: On boundary (triggers Rule 2, lower credit ok)
50000180500000 {Platinum}Assets boundary at 500000 in low income: On boundary for Rule 2
50000181999999{Platinum} Assets boundary at 1000000 in low income: Just below (Rule 2)
500001811000000{Platinum} Assets boundary at 1000000 in low income: On boundary (still Rule 2)
500001731000001{Platinum} Assets boundary at 1000000 in low income: Just above (triggers Rule 3)
500001721000001 {Platinum}Assets boundary at 1000000 in low income: Just above, credit too low for Rule 3
149999165499999{Platinum} Income boundary at 150000: Just below (triggers Rule 4 example)
150000165499999{Platinum} Income boundary at 150000: On boundary, qualifies under Group 2 (Rule 4)
150000146499999{Platinum} Income boundary at 150000: On boundary, low credit, falls to Group 3 (Rule 7)
150000145499999 {Platinum}Income boundary at 150000: On boundary, credit too low for both
199999146499999{Platinum} Income boundary at 200000: Just below (triggers Rule 7 example)
200000146499999{Platinum} Income boundary at 200000: On boundary (still Group 3, Rule 7)
200001125499999{Platinum} Income boundary at 200000: Just above (triggers Rule 10)
200001124499999 {Platinum}Income boundary at 200000: Just above, credit too low
  • Add these values to the Assert-Contact Sheet in rows 4 to 47, columns C to H
  • Click Save

Run the Test

Manual Run

The Test is now ready to be run. We will run the Test manually now and then set up the Test to run 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 (there should be 220 passes!)
       

      Test Results

Automated Testing

To execute the test alongside other tests, to set the test to run on a schedule or to execute the Test as part of an Azure DevOps pipeline we need to create a Test Runner record.

  • Navigate to TestShield > Test Runner
  • Click New
  • From the Test Runner tab, expand the relevant Test Plan and Test Suite nodes and select the Test (Platinum Credit Card)

  • Click the Test Runner Settings tab
    • Enter a name for the Test Runner, e.g. Test Runner - Platinum Credit Card
    • If you wanted to run this Test on a schedule you would configure the other fields to match your requirements. We are going to leave the Frequency to Once, as we want to execute this Test Runner configuration from Azure DevOps on demand as part of a pipeline
  • Click Save

Azure DevOps Pipeline

Executing the Test as part of an Azure DevOps pipeline is very easy to setup (prerequisite is to have installed the North52 Azure DevOps extension and set up the integration).

Once you have set up the Test Runner record, you simply need to add the North52 Execute Test Runner task to your pipeline:

  • Add an appropriate Display Name
  • Select the relevant Service Connection
  • Enter the Test Runner Name (note this needs to be exactly as the Test Runner record is named)

Run the pipeline and once completed, the results are available from the North52 TestShield page within the Test Plans section.