How to do it...

  1. Open your AL project in Visual Studio Code.
  2. In Explorer, select My Test.al and in the Editor, create a new test function:
[Test]
procedure TestConfirmHandler()
var
UiHandlerTest: TestPage "UI Handler Test";
begin
UiHandlerTest.OpenView();
UiHandlerTest.ConfirmTest.Invoke();
UiHandlerTest.OK().Invoke();
end;

If you deployed this test and ran it as it is right now, you should see the following test result:

What this means is that there is UI interaction happening within your test that is not being handled. Let's fix that!

  1. Add the HandlerFunctions attribute to your new test function, between the [Test] attribute and the function declaration, like this:
[Test]
[HandlerFunctions('HandleConfirmDialog')]
procedure TestConfirmHandler()
...

This tells the system that we expect to handle some UI and we will do that using a handler function named HandleConfirmDialog.

  1. Now, let's create the handler function by adding the following code:
[ConfirmHandler]
procedure HandleConfirmDialog(Question: Text[1024]; var Reply: Boolean)
begin
Reply := true;
end;

We used the ConfirmHandler attribute to specify that this function is for handling a confirmation dialog.

For this test, all we want to do is mimic the user, selecting Yes on the dialog window.

  1. Now, let's try out our test. Press F5 to build and publish the test app. In your development sandbox, follow these steps:
    1. Use the  icon to search for Test Tool and click the link to open it.
    2. Delete any existing entries in the page or create a new test suite.
    3. Select Process | Get Test Codeunits | Select Test Codeunits and press OK to view the list of all of the testing codeunits.
    4. Find the My Test entry and select it. Click OK.
    5. Select Run | All.

Now, the test results for our new test should show as a success:

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.223.213.238