Chapter 64. 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. 64.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. Note You cannot import any data objects while creating DMN-based test scenarios. DMN-based test scenarios do 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. 64.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. 64.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. 64.4. 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. Optional: 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. 64.5. 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. 64.6. 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. 64.7. 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. 64.8. Contextual menu options The test scenarios designer provides contextual menu options, which enables you to perform basic operations on the table such as adding, deleting, and, duplicating rows and columns. To use the contextual menus, you need to right-click a table element. Menu options differ based on the table element you select. Table 64.1. Contextual menu options Table element Cell label Available context menu options Header #, Scenario description Insert row below GIVEN, EXPECT Insert leftmost column, Insert rightmost column, Insert row below INSTANCE 1, INSTANCE 2, PROPERTY 1, PROPERTY 2 Insert column left, Insert column right, Delete column, Duplicate Instance, Insert row below Rows All the cells with row numbers, test scenarios description or test scenarios definition Insert row above, Insert row below, Duplicate row, Delete row, Run scenario Table 64.2. Description of table interactions Table interaction Description Insert leftmost column Inserts a new leftmost column (in either the GIVEN or EXPECT section of the table based on user selection). Insert rightmost column Inserts a new rightmost column (in either the GIVEN or EXPECT section of the table based on user selection). Insert column left Inserts a new column to the left of the selected column. The new column is of the same type as the selected column (in either the GIVEN or EXPECT section of the table based on user selection). Insert column right Inserts a new column to the right of the selected column. The new column is of the same type as the selected column (in either the GIVEN or EXPECT section of the table based on user selection). Delete column Deletes the selected column. Insert row above Inserts a new row above the selected row. Insert row below Inserts a new row below the selected row. If invoked from a header cell, inserts a new row with index 1. Duplicate row Duplicates the selected row. Duplicate Instance Duplicates the selected instance. Delete row Deletes the selected row. Run scenario Runs a single test scenario. The Insert column right or Insert column left context menu options behave differently. If the selected column does not have a type defined, a new column without a type is added. If the selected column has a type defined, either a new empty column or a column with the parent instance type is created. If the action is performed from an instance header, a new column without a type is created. If the action is performed from a property header, a new column with the parent instance type is created. 64.9. 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. 64.9.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. Note If 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. Optional: To skip the entire simulation from project level after test execution, select the check box. Click Save . 64.9.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. Optional: To skip the entire simulation from project level after test execution, select the check box. Click Save .

Commands: