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

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.

主站蜘蛛池模板: 怀安县| 阜新市| 略阳县| 乌兰察布市| 东乡族自治县| 绿春县| 孟连| 湘阴县| 革吉县| 英吉沙县| 香格里拉县| 正安县| 富阳市| 屏东市| 永登县| 白河县| 樟树市| 金湖县| 曲靖市| 西华县| 高陵县| 望奎县| 壤塘县| 达日县| 白河县| 贺兰县| 泰来县| 胶南市| 筠连县| 射洪县| 大港区| 调兵山市| 栾川县| 绥阳县| 禄劝| 张家口市| 兴城市| 香港| 浏阳市| 正镶白旗| 东海县|