Chapter 13. 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 scenarios 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 the three dots ( dotdotdotbutton ) in the upper-right corner of the page.
  3. Click Try SamplesMortgagesOK.

    The Assets window appears.

  4. Click Add AssetTest Scenario.
  5. 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.

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

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

    A blank test scenarios designer

    test scenarios preview editor

  10. Define the GIVEN column details,

    1. Click the cell named INSTANCE 1 under the GIVEN column header.
    2. From Test Tools panel, select LoanApplication data object.
    3. Click Add.
  11. To create properties of the data object, right-click the property 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.
  12. Click the first property cell,

    1. From Test Tools panel, select and expand the LoanApplication data object.
    2. Click amount and then Add to map the data object field to the property cell.
  13. Click the second property cell,

    1. From Test Tools panel, select and expand the LoanApplication data object.
    2. Click deposit and then Add.
  14. Click the third property cell,

    1. From Test Tools panel, select and expand the LoanApplication data object.
    2. Click lengthYears and then Add.
  15. Right-click LoanApplication header cell and select Insert column right. A new GIVEN column to the right is created.
  16. Click the new header cell,

    1. From Test Tools panel, select the IncomeSource data object.
    2. Click Add to map the data object to the header cell.
  17. Click the property cell below IncomeSource,

    1. From Test Tools panel, select and expand the IncomeSource data object.
    2. Click type and then Add to map the data object field to the property cell.

      You have now defined all the GIVEN column cells.

  18. Next, define the EXPECT column details,

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

    1. From Test Tools panel, select and expand the LoanApplication data object.
    2. Click approved and then Add to map the data object field to the property cell.
  21. Click the second property cell,

    1. From Test Tools panel, select and expand the LoanApplication data object.
    2. Click insuranceCost and then Add.
  22. Click the third property cell,

    1. From Test Tools panel, select and expand the LoanApplication data object.
    2. Click approvedRate and then Add.
  23. Now for defining 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 lenghtYears, 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.
  24. 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 lenghtYears, 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.
  25. After you have defined all GIVEN, EXPECT, and other data for the scenario, click Save in the test scenarios designer to save your work.
  26. 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.

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