RequestPageHandler Not Executing When Running Tests from VS Code
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:
- Create a test codeunit with a test procedure that calls a report with RunModal()
- Declare a RequestPageHandler in the test's HandlerFunctions attribute
- Use the VS Code "Run Test" or "Debug Test" to execute the test directly from the editor
- 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.
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
Familar with #8217
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.
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.
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
What versions of the platform and tools are you using?
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:
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.
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