Description

Test Data Rules are a key part of GenRocket's Self Service Test Data Portal. We organize all the Test Data Rule functionality into a part of the GenRocket platform we call "G-Rules".


Story

A QA Tester needs to generate customer data that includes the customer's name, account number, account balance, and a reward level based on each current account balance. Four reward levels can be assigned: 

  • Platinum
  • Gold
  • Silver
  • Bronze


When none of defined conditions are met, the reward level must be set to "Basic". A Test Data Rules Suite can be set up with the rules (i.e. business logic) for assigning the reward level based on each customer's account balance.


Test Data Rule 1

IF (Customer.balance >= 10000) 
THEN Customer.rewardLevel = "Platinum"


Test Data Rule 2

IF (Customer.balance >= 5000 && Customer.balance <= 9999)
THEN Customer.rewardLevel == "Gold"


Test Data Rule 3

IF (Customer.balance >= 2500 && Customer.balance <= 4999)
THEN Customer.rewardLevel == "Silver"


Test Data Rule 4

IF (Customer.balance >= 1000 && Customer.balance <= 2499)
THEN Customer.rewardLevel == "Bronze"


Default Test Data Rule

THEN Customer.rewardLevel == "Basic"


Domains and Attributes

A Customer Domain has been created with the following Attributes: 

  • id - Identifier for the Domain
  • firstName - Customer's first name.
  • middleInitial - Customer's middle initial.
  • lastName - Customer's last name. 
  • ssn - Customer's Social Security Number.
  • accountNumber - Customer's account number in the system.
  • balance - Customer's account balance in dollars.
  • rewardLevel - Assigned reward level based on the customer's account balance.

     

Let's follow the steps below to create our Test Data Rule Suite: 


Step 1: Add a Test Data Rule Suite

  • Select a Project within the Project Dashboard.
  • Expand the Self Serve Menu Options drop-down menu within the Project Versions Pane and select G-Rules.




  • Click the Add G-Rule Set button within the G-Rules Dashboard.



  • Enter a Name and Description for the Test Data Rule Suite.
  • Click the Save button.



  • The Test Data Rule Suite will appear as shown below: 


Step 2: Add and Configure Test Data Rule 1 - Platinum

A Test Data Rule will need to be created and configured for each of the conditions and corresponding actions shown at the beginning of this article. Test Data Rule 1 will be for the following condition and action:

IF (Customer.balance >= 10000)
THEN Customer.rewardLevel == "Platinum"


Step 2a: Add Test Data Rule 1

  • Click on the Add G-Rule button.



  • Enter a Description for the new Test Data Rule and click the Save button.



  • The new Test Data Rule will appear as shown below:


Step 2b: Add a Condition to Test Data Rule 1
  • Click the Add Condition button.



  • The configuration for this Condition is shown below. Click the Save button once finished.
    • Domain: Customer
    • Attribute: balance
    • Qualifier: >=
    • Value: 10000
    • Condition: THEN



  • The completed condition will appear as shown below for the Test Data Rule:


Step 2c: Add an Action to Test Data Rule 1

  • Click the New Action button.



  • The configuration is shown below: Click the Save button once finished.
    • Domain: Customer
    • Attribute: rewardLevel
    • Value Type: Constant
    • Value: Platinum



  • The completed Action will appear as shown below:


Step 3: Add and Configure Test Data Rule 2 - Gold

A Test Data Rule will need to be created and configured for each of the conditions and corresponding actions shown at the beginning of this article. Test Data Rule 2 will be for the following conditions and actions:

IF (Customer.balance >= 5000 && Customer.balance <= 9999)
THEN Customer.rewardLevel == "Gold"


Step 3a: Add Test Data Rule 2

  • Click on the Add G-Rule button.



  • Enter a Description for the new Test Data Rule and click the Save button.



  • The new Test Data Rule will appear as shown below:


Step 3b: Add the first Condition to Test Data Rule 2
  • Click the Add Condition button.



  • The configuration for this Condition is shown below. Click the Save button once finished.
    • Domain: Customer
    • Attribute: balance
    • Qualifier: >=
    • Value: 5000
    • Condition: AND



  • The completed condition will appear as shown below for the Test Data Rule:


Step 3c: Add the second Condition to Test Data Rule 2

  • Click the Add Condition button.



  • The configuration for this Condition is shown below. Click the Save button once finished.
    • Domain: Customer
    • Attribute: balance
    • Qualifier: <=
    • Value: 9999
    • Condition: THEN



  • The completed condition will appear as shown below for the Test Data Rule:


Step 3d: Add an Action to Test Data Rule 2

  • Click the New Action button.



  • The configuration is shown below: Click the Save button once finished.
    • Domain: Customer
    • Attribute: rewardLevel
    • Value Type: Constant
    • Value: Gold



  • The completed Action will appear as shown below:


Step 4: Add and Configure Test Data Rule 3 - Silver

A Test Data Rule will need to be created and configured for each of the conditions and corresponding actions shown at the beginning of this article. Test Data Rule 3 will be for the following conditions and action: 

IF (Customer.balance >= 2500 && Customer.balance <= 4999)
THEN Customer.rewardLevel == "Silver"


Step 4a: Add Test Data Rule 3

  • Click on the Add G-Rule button.



  • Enter a Description for the new Test Data Rule and click the Save button.



  • The new Test Data Rule will appear as shown below:


Step 4b: Add the first Condition to Test Data Rule 3
  • Click the Add Condition button.



  • The configuration for this Condition is shown below. Click the Save button once finished.
    • Domain: Customer
    • Attribute: balance
    • Qualifier: >=
    • Value: 2500
    • Condition: AND



  • The completed condition will appear as shown below for the Test Data Rule:


Step 4c: Add the second Condition to Test Data Rule 3

  • Click the Add Condition button.



  • The configuration for this Condition is shown below. Click the Save button once finished.
    • Domain: Customer
    • Attribute: balance
    • Qualifier: <=
    • Value: 4999
    • Condition: THEN



  • The completed condition will appear as shown below for the Test Data Rule:


Step 4d: Add an Action to Test Data Rule 3

  • Click the New Action button.



  • The configuration is shown below: Click the Save button once finished.
    • Domain: Customer
    • Attribute: rewardLevel
    • Value Type: Constant
    • Value: Silver



  • The completed Action will appear as shown below:


Step 5: Add and Configure Test Data Rule 4 - Bronze

A Test Data Rule will need to be created and configured for each of the conditions and actions shown at the beginning of this article. Test Data Rule 4 will be for the following conditions and action: 

IF (Customer.balance >= 1000 && <= 2499)
THEN Customer.rewardLevel == "Bronze"


Step 5a: Add Test Data Rule 4

  • Click on the Add G-Rule button.



  • Enter a Description for the new Test Data Rule and click the Save button.



  • The new Test Data Rule will appear as shown below:


Step 5b: Add the first Condition to Test Data Rule 4
  • Next, click the Add Condition button.



  • The configuration for this Condition is shown below. Click the Save button once finished.
    • Domain: Customer
    • Attribute: balance
    • Qualifier: >=
    • Value: 1000
    • Condition: AND



  • The completed condition will appear as shown below for the Test Data Rule:


Step 5c: Add the second Condition to Test Data Rule 4

  • Click the Add Condition button.



  • The configuration for this Condition is shown below. Click the Save button once finished.
    • Domain: Customer
    • Attribute: balance
    • Qualifier: <=
    • Value: 2499
    • Condition: THEN



  • The completed condition will appear as shown below for the Test Data Rule:



Step 5d: Add an Action to Test Data Rule 4

  • Click the New Action button.



  • The configuration is shown below: Click the Save button once finished.
    • Domain: Customer
    • Attribute: rewardLevel
    • Value Type: Constant
    • Value: Bronze



  • The completed Action will appear as shown below:


Step 6: Add a Default Test Data Rule

A Default Test Data Rule ensures a value is assigned when none of the defined conditions are met for all other Test Data Rules. For this example, the following Default Rule will be added: 

THEN Customer.rewardLevel == "Basic"


Step 6a: Add a Default Test Data Rule

  • Click on the Add G-Rule Default button.



  • Enter a Description and click the Save button.



  • The completed rule appears as shown below:


Step 6b: Add an Action to the Default Test Data Rule

Default Test Data Rules may have one or more actions, which are used when all defined conditions within the suite are not met. 

  • Click the New Action button.



  • The configuration is shown below. Click the Save button once finished.
    • Domain: Customer
    • Attribute: rewardLevel
    • Value Type: Constant
    • Value: Basic



  • The completed Action will appear as shown below:


Completed Story

Once this configuration is completed, you can download and run the Test Data Rule Suite with a Scenario, Scenario Chain, or Scenario Chain Set. It can also be added to a Test Data Case. The completed configuration is shown below: 



Sample Output