AL icon indicating copy to clipboard operation
AL copied to clipboard

RequestPageHandler Not Executing When Running Tests from VS Code

Open BB97GER opened this issue 7 months ago • 8 comments

1. Describe the bug

When running AL tests directly from Visual Studio Code RequestPageHandler procedures are not being executed. However, the same tests run correctly and the RequestPageHandler executes as expected when using the Test Runner Framework in the Business Central client.

2. To Reproduce

Steps to reproduce the behavior:

  1. Create a test codeunit with a test procedure that calls a report with RunModal()
  2. Declare a RequestPageHandler in the test's HandlerFunctions attribute
  3. Use the VS Code "Run Test" or "Debug Test" to execute the test directly from the editor
  4. The RequestPageHandler procedure does not execute

Minimal code snippet demonstrating the issue:

codeunit 60060 MyTestCodeunit
{
    Subtype = Test;

    [Test]
    [HandlerFunctions('RequestPageHandler')]
    procedure RequestPageHandlerTest()
    var
        Customer: Record Customer;
        CustomerDetailTrialBal: Report "Customer - Detail Trial Bal.";
    begin
        Customer.FindFirst();
        CustomerDetailTrialBal.SetTableView(Customer);
        Commit();
        CustomerDetailTrialBal.RunModal(); // Trigger RequestPageHandler
        Error('Unreachable!');
    end;

    [RequestPageHandler]
    procedure RequestPageHandler(var CustomerDetailTrialBal: TestRequestPage "Customer - Detail Trial Bal.")
    begin
        // Do Stuff
        Error('Test Error from Request Page Handler');
    end;
}

3. Expected behavior

When running the test from VS Code, the RequestPageHandler should be invoked when CustomerDetailTrialBal.RunModal() is called. The test should fail with the error message "Test Error from Request Page Handler" from the handler procedure.

4. Actual behavior

The RequestPageHandler is not executed at all. Instead, the test continues past the RunModal() call and fails with the error "Unreachable!" from the test procedure itself.

The same test works correctly when run through the Test Runner Framework in the Business Central web client - the RequestPageHandler executes as expected.

Image Image

5. Versions:

  • AL Language: 18.0.2293710
  • Visual Studio Code: 1.115.0
  • Business Central: Version: DE Business Central 28.0 (Platform 28.0.48678.0 + Application 28.0.46665.48767)
  • Operating System:
    • [x] Windows
    • [ ] Linux
    • [ ] MacOS

Final Checklist

Please remember to do the following:

  • [x] Search the issue repository to ensure you are reporting a new issue
  • [x] Reproduce the issue after disabling all extensions except the AL Language extension
  • [x] Simplify your code around the issue to better isolate the problem

BB97GER avatar Apr 14 '26 10:04 BB97GER

Familar with #8217

BB97GER avatar Apr 14 '26 10:04 BB97GER

I'm facing the same issue. I have tests that set up some data in the Request Page via the RequestHandler that are not populated when running from vscode test tool, but work correctly when running the same test from the Business Central AL Tool.

aacnsilva avatar May 28 '26 11:05 aacnsilva

Hi @BB97GER

We have made a couple of changes since the issue was raised, and I believe this is fixed. Can you please have a try with the last preview build of the platform and AL Language extension.

thpeder avatar Jul 28 '26 08:07 thpeder

Hi @thpeder, this is still not running from the vscode test runner. The tests fail running from vscode but run correctly from the BC AL Test Tool. They fail because the values are not being set/retrieved from the RequestPageHandler

aacnsilva avatar Jul 29 '26 11:07 aacnsilva

What versions of the platform and tools are you using?

thpeder avatar Jul 29 '26 12:07 thpeder

I'm using the following: Env:

"platform": "28.0.0.0",
"application": "28.0.0.0",
"runtime": "17.0"

Version: W1 28.0 (Platform 28.0.48460.0 + Application 28.0.46665.48549)

Tools:

Image

aacnsilva avatar Jul 29 '26 12:07 aacnsilva

Thanks for the reply.

I have made the change in version 28, so one option is for you to wait for it to get rolled out, another option is to try out version 29 by provisioning a new preview Sandbox environment or getting a docker image for version 29.

thpeder avatar Aug 05 '26 12:08 thpeder

I'll close the issue, Please open a new one if you still encounter the issue in a version 29 or a recent build of 28

thpeder avatar Aug 12 '26 08:08 thpeder