Chapter 15. Creating test scenario using the sample Mortgages project

This chapter illustrates creating and executing a test scenario from the sample Mortgages project shipped with Business Central using the test scenario designer. The test scenario example in this chapter is based on the Pricing loans guided decision table from the Mortgages project.

Procedure

  1. In Business Central, go to MenuDesignProjects and click Mortgages.
  2. If the project is not listed under Projects, from MySpace, click Try SamplesMortgagesOK.

    The Assets window appears.

  3. Click Add AssetTest Scenario.
  4. Enter scenario_pricing_loans as the Test Scenario name and select the default mortgages.mortgages package from the Package drop-down list.

    The package you select must contain all the required rule assets.

  5. Select RULE as the Source type.
  6. Click Ok to create and open the test scenario in the test scenario designer.
  7. Expand Project Explorer and verify the following:

    • Applicant, Bankruptcy, IncomeSource, and LoanApplication data objects exist.
    • Pricing loans guided decision table exists.
    • Verify that the new test scenario is listed under Test Scenario
  8. After verifying that everything is in place, return to the Model tab of the test scenario designer and define the GIVEN and EXPECT data for the scenario, based on the available data objects.

    Figure 15.1. A blank test scenario designer

    test scenarios blank preview editor
  9. Define the GIVEN column details:

    1. Click the cell named INSTANCE 1 under the GIVEN column header.
    2. From the Test Tools panel, select the LoanApplication data object.
    3. Click Insert Data Object.
  10. To create properties for the data object, right-click the property header cell and select Insert column right or Insert column left as required. For this example, you need to create two more property cells under the GIVEN column.
  11. Select the first property header cell:

    1. From the Test Tools panel, select and expand the LoanApplication data object.
    2. Click amount.
    3. Click Insert Data Object to map the data object field to the property header cell.
  12. Select the second property header cell:

    1. From the Test Tools panel, select and expand the LoanApplication data object.
    2. Click deposit.
    3. Click Insert Data Object.
  13. Select the third property header cell:

    1. From the Test Tools panel, select and expand the LoanApplication data object.
    2. Click lengthYears
    3. Click Insert Data Object.
  14. Right-click the LoanApplication header cell and select Insert column right. A new GIVEN column to the right is created.
  15. Select the new header cell:

    1. From the Test Tools panel, select the IncomeSource data object.
    2. Click Insert Data Object to map the data object to the header cell.
  16. Select the property header cell below IncomeSource:

    1. From the Test Tools panel, select and expand the IncomeSource data object.
    2. Click type.
    3. Click Insert Data Object to map the data object field to the property header cell.

      You have now defined all the GIVEN column cells.

  17. Next, define the EXPECT column details:

    1. Click the cell named INSTANCE 2 under the EXPECT column header.
    2. From the Test Tools panel, select LoanApplication data object.
    3. Click Insert Data Object.
  18. To create properties for the data object, right-click the property header cell and select Insert column right or Insert column left as required. Create two more property cells under the EXPECT column.
  19. Select the first property header cell:

    1. From the Test Tools panel, select and expand the LoanApplication data object.
    2. Click approved.
    3. Click Insert Data Object to map the data object field to the property header cell.
  20. Select the second property header cell:

    1. From the Test Tools panel, select and expand the LoanApplication data object.
    2. Click insuranceCost.
    3. Click Insert Data Object to map the data object field to the property header cell.
  21. Select the third property header cell:

    1. From the Test Tools panel, select and expand the LoanApplication data object.
    2. Click approvedRate.
    3. Click Insert Data Object to map the data object field to the property header cell.
  22. To define the test scenario, enter the following data in the first row:

    • Enter Row 1 test scenario as the Scenario Description, 150000 as the amount, 19000 as the deposit, 30 as the lengthYears, and Asset as the type for the GIVEN column values.
    • Enter true as approved, 0 as the insuranceCost and 2 as the approvedRate for the EXPECT column values.
  23. Next enter the following data in the second row:

    • Enter Row 2 test scenario as the Scenario Description, 100002 as the amount, 2999 as the deposit, 20 as the lengthYears, and Job as the type for the GIVEN column values.
    • Enter true as approved, 10 as the insuranceCost and 6 as the approvedRate for the EXPECT column values.
  24. After you have defined all GIVEN, EXPECT, and other data for the scenario, click Save in the test scenario designer to save your work.
  25. Click Run Test in the upper-right corner to run the .scesim file.

    The test result is displayed in the Test Report panel. Click View Alerts to display messages from the Alerts section. If a test fails, refer to the messages in the Alerts section at the bottom of the window, review and correct all components in the scenario, and try again to validate the scenario until the scenario passes.

  26. Click Save in the test scenario designer to save your work after you have made all necessary changes.