Refresh tests in AL Test Runner executes OnRun without Isolation
1. Describe the bug When you have test codeunits and you refresh them in the AL Test Runner page (Page 130451, Action = Update Test Methods), the OnRun trigger of all codeunits get execute without proper isolation. This means when you want to setup data in the OnRun trigger, which works fine when your execute your test, it now actually creates (or deletes) data in the database. This can cause unexpected issues and unwanted data in your database.
2. To Reproduce Create a new test codeunit with an OnRun trigger that deletes or inserts data in the database. Goto the page AL Test Tool (130451) and load the test codeunits. Use the action 'Update test Methods' in the ribbon. Check the data in the database, this is now actually changed.
codeunit 50000 "Dummy Test"
{
Subtype = Test;
trigger OnRun()
var
Customer: Record Customer;
begin
Customer.DeleteAll(false);
end;
[Test]
procedure CountCustomersShouldBeMoreThanZero()
var
Customer: Record Customer;
Assert: Codeunit "Library Assert";
begin
Assert.AreNotEqual(0, Customer.Count(), 'Where are my customers?');
end;
}
3. Expected behavior No changes in the database actually happen.
4. Actual behavior The data in the database is changed.
5. Versions:
- AL Language: 7.4
- Visual Studio Code: 1.58.2
- Business Central: 18.0
Let's get the issue to a team who will fix and backport it, as this repository is only for issues related to the AL compiler in latest developer preview environment for Dynamics 365 Business Central. We suggest that you open a support case or file a bug in Collaborate, to ensure that all Business Central users benefit from your catch as soon as possible.
To open a support case, you can:
- Open a support request to CSS through the PartnerSource portal
- Contact your Service Account Manager (SAM) in your local subsidiary to understand what is included in your contract as of support incident and PAH (Partner Advisory Hours). Your SAM might also direct you "step by step" how to open a support request or how to get credentials, if this is the first time for you or your company
If you file the bug in Collaborate, remember to include steps to reproduce the issue, and the Business Central build number and country version you're using.
also posted on https://www.yammer.com/dynamicsnavdev/#/Threads/show?threadId=1360425977389056