官术网_书友最值得收藏!

Test Tool

Goal: Understand what the Test Tool entails and learn how to use and apply it.

The Test Tool is a standard application feature that allows you to manage and run the automated tests that reside in the database, and collect their results, be they test codeunits that belong to the standard application or that are part of extensions. With the various hands-on example tests, we will be using this tool a lot. However, before we do this, let's elaborate a little bit on it.

You can easily access the Test Tool using the TELL ME WHAT YOU WANT TO DO feature in Dynamics 365 Business Central, as displayed in the following screenshot:

When in a clean database, or at least a database or company where the Test Tool has not been used yet, this is how the Test Tool appears. A suite called DEFAULT with no records in it appears, as seen as follows:

To populate the suite take the following steps:

  1. Select the Get Test Codeunits action.
  2. On the dialog that opens, you have the following two options:
    • Select Test Codeunits: This will open a list page showing all test codeunits that are present in the database from which you can select specific test codeunits; once you have selected and clicked OK, these codeunits will be added to the suite
    • All Test Codeunits: This will add all test codeunits that exist in the database to the test suite

Let's select the first option, Select Test Codeunits. This will open the CAL Test Get Codeunits page. Unsurprisingly, it shows the four test codeunits we have created in Chapter 2, The Testability Framework, followed by the long list of over 700 standard test codeunits:

  1. Select the four test codeunits 60000 through 60003 and click OK.

The suite now shows for each test Codeunit a line with LINE TYPE = Codeunit and, linked to this line and indented, all its test functions (LINE TYPE = Function) as shown in the following screenshot:

  1. To run the tests, select the Run action.
  1. On the following dialog that opens, with options Active Codeunit and All, select All and press OK. Now all four test codeunits will be run and each test will yield a result, Success or Failure:

Had we selected the option Active Codeunit only, the selected codeunit would have been executed.

For each failure, the First Error field will display the error that caused the failure. As you can see, First Error is a FlowField. If you drill down into it, the CAL Test Result window opens. This displays the whole test run history for a specific test.
Note that the message dialog in MyFirstTestCodeunit yields an Unhandled UI error.

Running the test by selecting Run will call the standard test runner codeunit CAL Test Runner (130400) and will make sure that the following happen:

  • Tests run from the Test Tool will be run in isolation
  • The results of each test function will be logged

In this short overview of the Test Tool, we used the following features:

  • Get test codeunits
  • Creating multiple test suites

When diving into test coding, the Test Tool will be our companion. There we will be using various other features of it, including the following:

  • Run selected
  • Drilling into the test results
  • Referencing the call stack
  • Clearing the results
  • Test coverage map

Regarding on-premises installation: The Test Tool can be accessed and executed using an end-user license. This has been enabled since the fall of 2017.

主站蜘蛛池模板: 诸暨市| 南华县| 锦屏县| 额尔古纳市| 兴义市| 监利县| 固镇县| 井陉县| 咸阳市| 柘城县| 武乡县| 自治县| 大城县| 开江县| 锡林郭勒盟| 同仁县| 韶山市| 东丰县| 正宁县| 宜春市| 宁乡县| 门头沟区| 陆河县| 华亭县| 澳门| 合川市| 集安市| 绍兴县| 庆云县| 大埔区| 宣化县| 锡林浩特市| 湟中县| 吴旗县| 武定县| 镇雄县| 隆昌县| 达孜县| 连平县| 浙江省| 晋州市|