With the helper function, we touch on the core of this test example – making use of a test page to achieve #0007, that is, testing that the user can assign a default customer category to a specific customer. The following is what the helper function looks like:
local procedure
SelectAssignDefaultCategoryActionOnCustomerCard(
CustomerNo: Code[20])
var
CustomerCard: TestPage "Customer Card";
begin
CustomerCard.OpenView();
CustomerCard.GoToKey(CustomerNo);
CustomerCard."Assign default category".Invoke();
end;
Note that I did not use a with-do construct to unambiguously show that the three statements in the function are referencing methods that you will only find on test page objects, and not on normal pages:
- OpenView: Opens the test page in view mode
- GoToKey: Finds the row in a dataset that is identified by the specified values
- Invoke: Invokes an action on a test page
For a complete listing of all test page methods, take a look at the following URLs:
- TestPage: https://docs.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/methods-auto/testpage/testpage-data-type
- TestField: https://docs.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/methods-auto/testfield/testfield-data-type
- TestAction: https://docs.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/methods-auto/testaction/testaction-data-type
You can find more details on test pages in Luc's book at https://www.packtpub.com/business/automated-testing-microsoft-dynamics-365-business-central.