Skip to content

RequestPageHandler Not Executing When Running Tests from VS Code #8233

@BB97GER

Description

@BB97GER

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:
    • Windows
    • Linux
    • MacOS

Final Checklist

Please remember to do the following:

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions