- Automated Testing in Microsoft Dynamics 365 Business Central
- Luc van Vugt
- 363字
- 2021-06-24 14:56:53
Standard libraries
Goal: Get to know the basics about the standard test helper libraries provided by Microsoft.
Supporting their standard tests, Microsoft has created a nice and very useful collection of helper functions in more than 70 library codeunits. These helper functions range from random data generations and master data generation to standard generic and more specific check routines.
Need a new item? You might make use of the CreateItem or CreateItemWithoutVAT helper functions in Library - Inventory (codeunit 132201).
Need a random text? Use the RandText helper function in Library – Random (codeunit 130440).
Want to get the same formatted error messages when verifying your test outcome? Use one of the helper functions in the Assert (codeunit 130000), such as IsTrue, AreNotEqual, and ExpectedError.
A frequently reappearing question during my workshops is:
Unfortunately, there is no overview of all available helper functions for Dynamics 365 Business Central. However, up to NAV 2018, a .chm help file containing this information was included in the TestToolKit folder on the product DVD. You might want to make use of this, but I always use a very simple method. Having all our code in a source code management system, I can do a quick file search in the standard test objects folder. In case I need a helper that will create me a service item, I might open VS Code on that folder and search for CreateServiceItem, as shown in the following screenshot:

In Section 3, Designing and Building Automated Tests for Microsoft Dynamics 365 Business Central, of this book, when building tests, we will happily make use of various standard helper functions, making our work much more efficient and consistent.
130000 to 133999: w1 test helper libraries
Note that all test tool objects also reside in the lower part of this range:
140000 to 143999: local test helper libraries
More on unit and functional tests? Go to:
https://www.softwaretestinghelp.com/the-difference-between-unit-integration-and-functional-testing/