1. Describe the bug
IΓÇÖve been looking into running Business Central tests directly from VS Code. Until now, IΓÇÖve been using the AL Test Tool to run the tests. All my tests have run successfully there. The tests also run successfully in GitHub Pipelines and Azure DevOps Pipelines. However, when I run the same test on the same database in the same tenant from VS Code, the test fails. One possible cause seems to be the different handling of GuiAllowed(). In the AL Test Tool, GuiAllowed = true is returned (and apparently also when running tests in pipelines). When running tests from VS Code, GuiAllowed = false was returned.
Consequently, the ConfirmHandlers in the tests that relied on this were no longer executed, causing the tests to fail.
I think the runtime environment should return the same values for system functions (and in particular GuiAllowed) regardless of where a test is called from. I expect the value to be the same as it is returned in the AL Test Tool to ensure backward compatibility.
2. To Reproduce
-
Create an app that includes a confirmation prompt in a process. For example, something like this:
-
Create a test in a test codeunit that uses this function. The test function should have a ConfirmHandler. For example, like this:
-
Run the test once from the AL Test Tool in the client -> The test should succeed
-
Run the test from VS Code. The test fails because the ConfirmHandler was not executed.
Code to copy into a TestCodeunit:
procedure ShowConfirm(ConfirmQst: Text): Boolean
begin
if GuiAllowed() then begin
Commit();
exit(Confirm(ConfirmQst));
end;
exit(true);
end;
[Test]
[HandlerFunctions('GuiallowedFlagConfirmHandler')]
procedure TestGuiallowedFlag()
begin
ShowConfirm('Test Confirm');
end;
[ConfirmHandler]
procedure GuiallowedFlagConfirmHandler(Question: Text[1024]; var Reply: Boolean)
begin
Reply := true;
end;
Note: Because the developers need to copy and paste the code snippet, including a code snippet as a media file (i.e. .gif) is not sufficient.
3. Expected behavior
I think the runtime environment should return the same values for system functions (and in particular GuiAllowed) regardless of where a test is called from. I expect the value to be the same as it is returned in the AL Test Tool to ensure backward compatibility.
4. Actual behavior
See the description above
5. Versions:
- AL Language: 18.0.2190758
- Visual Studio Code:
- Business Central: W1 29.0 (Platform 29.0.47575.0 + Application 29.0.47628.0)
- List of Visual Studio Code extensions that you have installed: AL Language
- Operating System:
Final Checklist
Please remember to do the following:
Internal work item: AB#630907
1. Describe the bug
IΓÇÖve been looking into running Business Central tests directly from VS Code. Until now, IΓÇÖve been using the AL Test Tool to run the tests. All my tests have run successfully there. The tests also run successfully in GitHub Pipelines and Azure DevOps Pipelines. However, when I run the same test on the same database in the same tenant from VS Code, the test fails. One possible cause seems to be the different handling of GuiAllowed(). In the AL Test Tool, GuiAllowed = true is returned (and apparently also when running tests in pipelines). When running tests from VS Code, GuiAllowed = false was returned.
Consequently, the ConfirmHandlers in the tests that relied on this were no longer executed, causing the tests to fail.
I think the runtime environment should return the same values for system functions (and in particular
GuiAllowed) regardless of where a test is called from. I expect the value to be the same as it is returned in the AL Test Tool to ensure backward compatibility.2. To Reproduce
Create an app that includes a confirmation prompt in a process. For example, something like this:
Create a test in a test codeunit that uses this function. The test function should have a ConfirmHandler. For example, like this:
Run the test once from the AL Test Tool in the client -> The test should succeed
Run the test from VS Code. The test fails because the ConfirmHandler was not executed.
Code to copy into a TestCodeunit:
Note: Because the developers need to copy and paste the code snippet, including a code snippet as a media file (i.e. .gif) is not sufficient.
3. Expected behavior
I think the runtime environment should return the same values for system functions (and in particular
GuiAllowed) regardless of where a test is called from. I expect the value to be the same as it is returned in the AL Test Tool to ensure backward compatibility.4. Actual behavior
See the description above
5. Versions:
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
Internal work item: AB#630907