Chapter 65. 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.
65.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
-
In Business Central, go to Menu
Design Projects and click the project for which you want to create the test scenario. -
Click Add Asset
Test Scenario. - 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.
- Select RULE as the Source type.
- Click Ok to create and open the test scenario in the test scenarios designer.
To map the GIVEN column header to a data object:
Figure 65.1. Test scenario GIVEN header cells
- Select an instance header cell in the GIVEN section.
- Select the data object from the Test Tools tab.
- Click Insert Data Object.
To map the EXPECT column header to a data object:
Figure 65.2. Test scenario EXPECT header cells
- Select an instance header cell in the EXPECT section.
- Select the data object from the Test Tools tab.
- Click Insert Data Object.
To map a data object field to a property cell:
- Select an instance header cell or property header cell.
- Select the data object field from the Test Tools tab.
- Click Insert Data Object.
- To insert more properties of the data object, right-click the property header and select Insert column right or Insert column left as required.
To define a java method to a property cell during test scenarios execution:
- Select an instance header cell or property header cell.
- Select the data object field from the Test Tools tab.
- Click Insert Data Object.
- Use the MVEL expression with the prefix # to define a java method for test scenario execution.
- 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.
- 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 70.1, “Expression syntax in rule-based test scenarios”.
65.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.