OnBeforeTestRun/OnAfterTestRun are not raised in devpreview
Hello,
When you have TestRunner codeunit in extension, its' OnBeforeTestRun and OnAfterTestRun functions are not called. I'm using latest microsoft/dynamics-nav:devpreview image.
pageextension 50100 CustomerListExt extends "Customer List"
{
trigger OnOpenPage();
begin
// This will not raise error.
Codeunit.Run(Codeunit::"My Test Runner");
// This will raise error.
//Codeunit.Run(50000);
end;
}
codeunit 50101 "My Tests"
{
Subtype = Test;
[Test]
procedure Succeeds();
begin
Error('Fails.');
end;
}
codeunit 50100 "My Test Runner"
{
Subtype = TestRunner;
TestIsolation = Codeunit;
trigger OnRun();
begin
Codeunit.Run(Codeunit::"My Tests");
end;
procedure OnBeforeTestRun(CodeunitID : Integer;CodeunitName : Text[30];FunctionName : Text[128];Permissions : TestPermissions) Ok : Boolean;
begin
Error('OnBeforeTestRun is not called.');
end;
procedure OnAfterTestRun(CodeunitID : Integer;CodeunitName : Text[30];FunctionName : Text[128];Permissions : TestPermissions; Success : Boolean);
begin
Error('OnAfterTestRun is not called.');
end;
}
Test runner to import manually: COD50000.TXT
PS. I am trying to create extension that imports all records or none from CSV and shows errors if any. TestRunner is needed to rollback COMMITs.
PS. Docker image info:
"Labels": {
"country": "W1",
"created": "201711091201",
"cu": "november",
"eula": "https://go.microsoft.com/fwlink/?linkid=861843",
"legal": "http://go.microsoft.com/fwlink/?LinkId=837447",
"maintainer": "Freddy Kristiansen",
"nav": "devpreview",
"osversion": "10.0.14393.1770",
"tag": "0.0.3.3",
"version": "11.0.19097.0"
}
PS. 2. The above code should raise error because ERROR function is used in OnBeforeTestRun and OnAfterTestRun functions.
PS. 3. I am using AL Language extension 0.11.14434.
Have you regenerated symbols using C/SIDE after importing and compiling COD50000?
Codeunit 50000 is OK. It's the test runner inside extension that does not work. In example code, error should be thrown because error function is written inside OnBeforeTestRun and OnAfterTestRun functions.
I have the same issue. It's not running the before and after triggers however, if the after trigger is placed it realises that it should not show the Message with test results. Using extension 0.12...
Any news on this??
Sorry for taking such a long time to get to this. I've found the root cause and I am working on a fix. More than anything, it looks like the problem was with the emission of the Error call.