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,

    1. Click an instance header in the GIVEN section.
    2. Select the data object from the Test Tools tab.
    3. Click Add.
  7. To insert more properties of the data object, right-click the property header and select Insert column right or Insert column left as required.
  8. To map a data object field to a property cell,

    1. Click a property cell.
    2. Select the data object field from the Test Tools tab.
    3. Click Add.
  9. To map the EXPECT column header to a data object,

    1. Click an instance header in the EXPECT section.
    2. Select the data object from the Test Tools tab.
    3. Click Add.
  10. To insert more properties of the data object, right-click the property header and select Insert column right or Insert column left as required.
  11. To map a data object field to a property cell,

    1. Click a property cell.
    2. Select the data object field from the Test Tools tab.
    3. Click Add.

      Use the contextual menu to add or remove columns as needed.

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.