Chapter 4. Test scenarios


Test scenarios in Red Hat Process Automation Manager enable you to validate the functionality of business rules and business rule data (for rules-based test scenarios) or of DMN models (for DMN-based test scenarios) before deploying them into a production environment. With a test scenario, you use data from your project to set given conditions and expected results based on one or more defined business rules. When you run the scenario, the expected results and actual results of the rule instance are compared. If the expected results match the actual results, the test is successful. If the expected results do not match the actual results, then the test fails.

Red Hat Process Automation Manager currently supports both the new Test Scenarios designer and the former Test Scenarios (Legacy) designer. The default designer is the new test scenarios designer, which supports testing of both rules and DMN models and provides an enhanced overall user experience with test scenarios. If required, you can continue to use the legacy test scenarios designer, which supports rule-based test scenarios only.

You can run the defined test scenarios in a number of ways, for example, you can run available test scenarios at the project level or inside a specific test scenario asset. Test scenarios are independent and cannot affect or modify other test scenarios. You can run test scenarios at any time during project development in Business Central. You do not have to compile or deploy your decision service to run test scenarios.

You can import data objects from different packages to the same project package as the test scenario. Assets in the same package are imported by default. After you create the necessary data objects and the test scenario, you can use the Data Objects tab of the test scenarios designer to verify that all required data objects are listed or to import other existing data objects by adding a New item.

Important

Throughout the test scenarios documentation, all references to test scenarios and the test scenarios designer are for the new version, unless explicitly noted as the legacy version.

4.1. Testing the traffic violations using test scenarios

Use the test scenarios designer in Business Central to test the DMN decision requirements diagrams (DRDs) and define decision logic for the traffic violations project.

Figure 4.1. Test scenario for the traffic violations example

dmn gs traffic violation test scenarios

Prerequisites

  • You have successfully built the traffic violations project in Business Central.

Procedure

  1. On the traffic-violation project’s home screen, click Add Asset to open the Add Asset screen.
  2. Click Test Scenario to open the Create new Test Scenario dialog.

    1. Enter Violation Scenarios in the Test Scenario field.
    2. From the Package list, select com.myspace.traffic_violation.
    3. Select DMN as the Source type.
    4. From the Choose a DMN asset list, select the path to the DMN asset.
    5. Click Ok to open the Violation Scenarios test scenario in the Test Scenarios designer.
  3. Under Driver column sub-header, right-click the State, City, Age, and Name value cells and select Delete column from the context menu options to remove them.
  4. Under Violation column sub-header, right-click the Date and Code value cells and select Delete column to remove them.
  5. Enter the following information in the first row of the test scenarios:

    • Scenario description: Above speed limit: 10km/h and 30 km/h
    • Points (under Given column header): 10
    • Type: "speed"
    • Speed Limit: 100
    • Actual Speed: 120
    • Points: 3
    • Amount: 500
    • Should the driver be suspended?: "No"

      Right-click the first row and select Insert row below to add another row.

  6. Enter the following information in the second row of the test scenarios:

    • Scenario description: Above speed limit: more than 30 km/h
    • Points (under Given column header): 10
    • Type: "speed"
    • Speed Limit: 100
    • Actual Speed: 150
    • Points: 7
    • Amount: 1000
    • Should the driver be suspended?: "No"

      Right-click the second row and select Insert row below to add another row.

  7. Enter the following information in the third row of the test scenarios:

    • Scenario description: Parking violation
    • Points (under Given column header): 10
    • Type: "parking"
    • Speed Limit: leave blank
    • Actual Speed: leave blank
    • Points: 1
    • Amount: 100
    • Should the driver be suspended?: "No"

      Right-click the third row and select Insert row below to add another row.

  8. Enter the following information in the fourth row of the test scenarios:

    • Scenario description: DUI violation
    • Points (under Given column header): 10
    • Type: "driving under the influence"
    • Speed Limit: leave blank
    • Actual Speed: leave blank
    • Points: 5
    • Amount: 1000
    • Should the driver be suspended?: "No"

      Right-click the fourth row and select Insert row below to add another row.

  9. Enter the following information in the fifth row of the test scenarios:

    • Scenario description: Driver suspended
    • Points (under Given column header): 15
    • Type: "speed"
    • Speed Limit: 100
    • Actual Speed: 140
    • Points: 7
    • Amount: 1000
    • Should the driver be suspended?: "Yes"
  10. Click Save.
  11. Click the Play icon dmn play icon to check whether the test scenarios pass or fail.

    Figure 4.2. Test scenario execution result for the traffic violations example

    dmn gs test scenarios execution results

    In case of failure, correct the errors and run the test scenarios again.

Red Hat logoGithubRedditYoutubeTwitter

Learn

Try, buy, & sell

Communities

About Red Hat Documentation

We help Red Hat users innovate and achieve their goals with our products and services with content they can trust.

Making open source more inclusive

Red Hat is committed to replacing problematic language in our code, documentation, and web properties. For more details, see the Red Hat Blog.

About Red Hat

We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.

© 2024 Red Hat, Inc.