Chapter 4. Test scenario template

Before specifying test scenario definitions, you need to create a test scenario template. The header of the test scenario table defines the template for each scenario. You need to set the types of the instance and property headers for both the GIVEN and EXPECT sections. Instance headers map to a particular data object (a fact), whereas the property headers map to a particular field of the corresponding data object.

Using the test scenarios designer, you can create test scenario templates for both rule-based and DMN-based test scenarios.

4.1. Creating a test scenario template for rule-based test scenarios

Create a test scenario template for rule-based test scenarios by following the procedure below to validate your rules and data.

Procedure

  1. In Business Central, go to MenuDesignProjects and click the project for which you want to create the test scenario.
  2. Click Add AssetTest Scenario.
  3. Enter a Test Scenario name and select the appropriate Package. The package you select must contain all the required data objects and rule assets have been assigned or will be assigned.
  4. Select RULE as the Source type.
  5. Click Ok to create and open the test scenario in the test scenarios designer.
  6. To map the GIVEN column header to a data object:

    Figure 4.1. Test scenario GIVEN header cells

    test scenario GIVEN header cells
    1. Select an instance header cell in the GIVEN section.
    2. Select the data object from the Test Tools tab.
    3. Click Insert Data Object.
  7. To map the EXPECT column header to a data object:

    Figure 4.2. Test scenario EXPECT header cells

    test scenario EXPECT header cells
    1. Select an instance header cell in the EXPECT section.
    2. Select the data object from the Test Tools tab.
    3. Click Insert Data Object.
  8. To map a data object field to a property cell:

    1. Select an instance header cell or property header cell.
    2. Select the data object field from the Test Tools tab.
    3. Click Insert Data Object.
  9. To insert more properties of the data object, right-click the property header and select Insert column right or Insert column left as required.
  10. To define a java method to a property cell during test scenarios execution:

    1. Select an instance header cell or property header cell.
    2. Select the data object field from the Test Tools tab.
    3. Click Insert Data Object.
    4. Use the MVEL expression with the prefix # to define a java method for test scenario execution.
    5. To insert more properties of the data object, right-click the property header cell and select Insert column right or Insert column left as required.
  11. Use the contextual menu to add or remove columns and rows as needed.

For more details about the expression syntax in rule-based scenarios, see Section 9.1, “Expression syntax in rule-based test scenarios”.

4.2. Using aliases in rule-based test scenarios

In the test scenarios designer, once you map a header cell with a data object, the data object is removed from the Test Tools tab. You can re-map a data object to another header cell by using an alias. Aliases enable you to specify multiple instances of the same data object in a test scenario. You can also create property aliases to rename the used properties directly in the table.

Procedure

In the test scenarios designer in Business Central, double-click a header cell and manually change the name. Ensure that the aliases are uniquely named.

The instance now appears in the list of data objects in the Test Tools tab.