Chapter 3. Test scenarios designer in Business Central
The test scenarios designer provides a tabular layout that helps you in defining a scenario template and all the associated test cases. The designer layout consists of a table which has a header and the individual rows. The header consists of three parts, the GIVEN and EXPECT row, a row with instances, and a row with corresponding fields. The header is also known as test scenario template and the individual rows are called test scenarios definitions.
The test scenario template or header has the following two parts:
- GIVEN data objects and their fields - represents the input information
- EXPECT data objects and their fields - represents the objects and their fields whose exact values are checked based on the given information and which also constitutes the expected result.
The test scenarios definitions represent the separate test cases of a template.
You can access the Project Explorer from the left panel of the designer whereas from the right panel you can access the Settings, Test Tools, Scenario Cheatsheet, Test Report and the Coverage Report tabs. You can access the Settings tab to view and edit the global settings of rule-based and DMN-based test scenarios. You can use the Test Tools to configure the data object mappings. Scenario Cheatsheet tab contains notes and the cheat sheet which you can use as reference. The Test Report tab displays the overview of the tests and the scenario status. To view the test coverage statistics, you can use the Coverage Report tab from the right side of the test scenario designer.
3.1. Importing data objects
The test scenarios designer loads all data objects that are located in the same package as the test scenario. You can view all the data objects from the Data Objects tab in the designer. The loaded data objects are also displayed in the Test Tools panel.
You need to close and reopen the designer in case the data objects change (for example, when a new data object is created or when an existing one is deleted). Select a data object from the list to display its fields and the field types.
In case you want to use a data object located in a different package than the test scenario, you need to import the data object first. Follow the procedure below to import a data object for rules-based test scenarios.
You cannot import any data objects while creating DMN-based test scenarios. DMN-based test scenarios does not use any data objects from the project but uses the custom data types defined in the DMN file.
Procedure
- Go to Project Explorer panel in the test scenarios designer.
- From Test Scenario, select a test scenario.
- Select Data Objects tab and click New Item.
- In the Add import window, choose the data object from the drop-down list.
- Click Ok and then Save.
- Close and reopen the test scenarios designer to view the new data object from the data objects list.
3.2. Importing a test scenario
You can import an existing test scenario using the Import Asset button in the Asset tab from the project view.
Procedure
-
In Business Central, go to Menu
Design Projects and click the project name. - From the project’s Asset tab, click Import Asset.
In the Create new Import Asset window,
- Enter the name of the import asset.
- Select the package from the Package drop-down list.
- From Please select a file to upload, click Choose File… to browse to test scenario file.
- Select the file and click Open.
- Click Ok and the test scenario opens in the test scenario designer.
3.3. Saving a test scenario
You can save a test scenario at any time while creating a test scenario template or defining the test scenarios.
Procedure
- From the test scenarios designer toolbar on the upper-right, click Save.
On the Confirm Save window,
- If you wish to add a comment regarding the test scenario, click add a comment.
- Click Save again.
A message stating that the test scenario was saved successfully appears on the screen.
3.4. Deleting a test scenario
You can delete existing test scenarios that were created using the test scenarios designer.
Procedure
- From the test scenarios designer toolbar on the upper-right, click Delete.
In the Confirm Delete window,
- To add a comment regarding the deletion of the test scenario, click add a comment.
- Click Delete.
A message stating that the test scenario was deleted successfully appears on the screen.
3.5. Renaming a test scenario
You can rename existing test scenarios by using the Rename button from the upper-right toolbar in the designer.
Procedure
- From the test scenarios designer toolbar on the upper-right, click Rename.
In the Rename Asset window,
- Enter a name in the Asset Name field.
- If you wish to add a comment, click add a comment.
Click Rename.
NoteClicking on Rename simply renames the test scenario file.
- From the test scenarios designer toolbar on the upper-right, click Save.
In the Confirm Save window,
- If you wish to add a comment, click add a comment.
- Click Save again.
- Alternately, you could click Save and Rename to save and rename the scenario at the same time.
A message stating that the test scenario was renamed successfully appears on the screen.
3.6. Copying a test scenario
You can copy an existing test scenario to the same package or to some other package by using the Copy button from the upper-right toolbar.
Procedure
- From the test scenarios designer toolbar on the upper-right, click Copy.
In the Make a Copy window,
- Enter a name in the New Name field.
- Select the package you want to copy the test scenario to.
- Optionally, to add a comment, click add a comment.
- Click Make a Copy.
A message stating that the test scenario was copied successfully appears on the screen.
3.7. Downloading a test scenario
You can download a copy of the test scenario to your local machine for future reference or as backup.
Procedure
In the test scenarios designer toolbar on the upper-right, click the Download icon.
The .scesim
file is downloaded to your local machine.
3.8. Switching between versions of a test scenario
Business Central provides you the ability to switch between the various versions of a test scenario. Every time you save the scenario, a new version of the scenario is listed under Latest Versions. To use this feature, you must save the test scenario file at least once.
Procedure
- From the test scenarios designer toolbar on the upper-right, click Latest Version. All the versions of the file are listed under Latest Version, if they exist.
Click the version you want to work on.
The selected version of the test scenario opens in the test scenarios designer.
- From the designer toolbar, click Restore.
In the Confirm Restore,
- To add a comment, click add a comment.
- Click Restore to confirm.
A message stating that the selected version has been reloaded successfully in the designer appears on the screen.
3.9. View or hide the alerts panel
The Alerts panel appears at the bottom of the test scenarios designer or the project view. It contains the build information and error messages in case the executed tests are failed.
Procedure
From the designer toolbar on the upper-right, click Hide Alerts/View Alerts to enable or disable the reporting panel.
3.11. Configuring global settings for test scenarios
You can use the global Settings tab on the right side of the test scenarios designer to set and modify the additional properties of assets.
3.11.1. Configuring global settings for rule-based test scenarios
Follow the procedure below to view and edit the global settings of rule-based test scenarios.
Procedure
- Click Settings tab on the right side of the test scenario designer to display the attributes.
Configure the following attributes in the Settings panel:
- Name: You can change the name of the existing test scenarios by using the Rename option from the upper-right toolbar in the designer.
- Type: This attribute specifies it is a rule-based test scenario and it is read-only.
Stateless Session: Select or clear this check box to specify if the KieSession is stateless or not.
NoteIf the current KieSession is stateless and the check box is not selected, the tests will fail.
- KieSession: (Optional) Enter the KieSession for the test scenario.
- RuleFlowGroup/AgendaGroup: (Optional) Enter the RuleFlowGroup or AgendaGroup for the test scenario.
- Optionally, to skip the entire simulation from project level after test execution, select the check box.
- Click Save.
3.11.2. Configuring global settings for DMN-based test scenarios
Follow the procedure below to view and edit the global settings of DMN-based test scenarios.
Procedure
- Click Settings tab on the right side of the test scenario designer to display the attributes.
Configure the following attributes in the Settings panel:
- Name: You can change the name of the existing test scenarios by using the Rename option from the upper-right toolbar in the designer.
- Type: This attribute specifies it is a DMN-based test scenario and it is read-only.
- DMN model: (Optional) Enter the DMN model for the test scenario.
- DMN name: This is the name of the DMN model and it is read-only.
- DMN namespace: This is the default namespace for DMN model and it is read-only.
- Optionally, to skip the entire simulation from project level after test execution, select the check box.
- Click Save.