此内容没有您所选择的语言版本。

Chapter 3. Test scenarios


Test scenarios in Red Hat Decision Manager enable you to validate the functionality of business rules and business rule data (for rules-based test scenarios) or the 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.

With the Test Scenarios designer, you execute all scenarios from the .scesim file at one time, whereas with the Test Scenarios (Legacy) designer, you can execute test scenarios one at a time or as a group. The group execution contains all the scenarios from one package. Test scenarios are independent, so one scenario cannot affect or modify the other. 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.

3.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 3.1. Test scenario for the traffic violations example

dmn gs traffic violation test scenarios

Prerequisite

  • You have successfully build 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 org.kie.example.traffic.traffic_violations.
    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 (under Expect column header): 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 (under Expect column header): 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: -
    • Actual Speed: -
    • Points (under Expect column header): 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 (under Expect column header): 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 (under Expect column header): 7
    • Amount: 1000
    • Should the driver be suspended?: "Yes"
  10. Click Save to open the Confirm Save dialog box and click Save again.
  11. Click the play button to check whether the test scenarios pass or fail.

    Figure 3.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

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

© 2024 Red Hat, Inc.