Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#437 Expose an event to skip suite errors #495

Merged
merged 12 commits into from
Feb 26, 2024
25 changes: 25 additions & 0 deletions src/Tools/Performance Toolkit/App/src/BCPTLine.Codeunit.al
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,15 @@ codeunit 149005 "BCPT Line"
var
BCPTLogEntry: Record "BCPT Log Entry";
BCPTRoleWrapperImpl: Codeunit "BCPT Role Wrapper"; // single instance
ValuesAreChanged: Boolean;
BCPTTestSuite: Codeunit "BCPT Test Suite";
ModifiedMessage, ModifiedOperation : Text;
NAVFreak marked this conversation as resolved.
Show resolved Hide resolved
ModifiedExecutionSuccess: Boolean;
begin
InitValuesSubscriberCanModify(Operation, ExecutionSuccess, Message, ModifiedExecutionSuccess, ModifiedMessage, ModifiedOperation);
BCPTTestSuite.OnBeforeBCPTLineAddLogEntry(BCPTLine."BCPT Code", BCPTLine."Codeunit ID", BCPTLine.Description, Operation, ExecutionSuccess, Message, ModifiedOperation, ModifiedExecutionSuccess, ModifiedMessage);
UpdateValuesFromSubscribers(Operation, ExecutionSuccess, Message, ModifiedExecutionSuccess, ModifiedMessage, ModifiedOperation);
NAVFreak marked this conversation as resolved.
Show resolved Hide resolved

BCPTLine.Testfield("BCPT Code");
BCPTRoleWrapperImpl.GetBCPTHeader(BCPTHeader);
Clear(BCPTLogEntry);
Expand Down Expand Up @@ -231,6 +239,23 @@ codeunit 149005 "BCPT Line"
Dimensions)
end;

local procedure UpdateValuesFromSubscribers(var Operation: Text; var ExecutionSuccess: Boolean; var Message: Text; var ModifiedExecutionSuccess: Boolean; var ModifiedMessage: Text; var ModifiedOperation: Text)
begin
if ModifiedExecutionSuccess <> ExecutionSuccess then
ExecutionSuccess := ModifiedExecutionSuccess;
if ModifiedMessage <> Message then
Message := ModifiedMessage;
if ModifiedOperation <> Operation then
Operation := ModifiedOperation;
end;

local procedure InitValuesSubscriberCanModify(var Operation: Text; var ExecutionSuccess: Boolean; var Message: Text; var ModifiedExecutionSuccess: Boolean; var ModifiedMessage: Text; var ModifiedOperation: Text)
NAVFreak marked this conversation as resolved.
Show resolved Hide resolved
NAVFreak marked this conversation as resolved.
Show resolved Hide resolved
begin
ModifiedMessage := Message;
ModifiedOperation := Operation;
ModifiedExecutionSuccess := ExecutionSuccess;
end;

procedure UserWait(var BCPTLine: Record "BCPT Line")
var
BCPTRoleWrapperImpl: Codeunit "BCPT Role Wrapper"; // single instance
Expand Down
18 changes: 18 additions & 0 deletions src/Tools/Performance Toolkit/App/src/BCPTTestSuite.Codeunit.al
Original file line number Diff line number Diff line change
Expand Up @@ -411,4 +411,22 @@ codeunit 149006 "BCPT Test Suite"
BCPTLine.SetRange("BCPT Code", SuiteCode);
BCPTLine.SetRange("Codeunit ID", CodeunitID);
end;

/// <summary>
/// This event is raised before a log entry is added to the BCPT Line table.
/// It can be used to skip errors which are not relevant for the test suite. Like unused handler functions.
/// </summary>
/// <param name="SuiteCode">The test suite code</param>
/// <param name="CodeunitId">The id of the test codunit that is being run</param>
/// <param name="Description">Description of the test on the "BCPT Line"</param>
/// <param name="Orig. Operation">Original operation that is currently executed</param>
/// <param name="Orig. ExecutionSuccess">The original ExecutionSuccess</param>
/// <param name="Orig. Message">The original message</param>
/// <param name="Operation">Replacement operation that is currently executed</param>
/// <param name="ExecutionSuccess">Replacement ExcecutionSuccess</param>
/// <param name="Message">Replacement Message</param>
[IntegrationEvent(false, false)]
procedure OnBeforeBCPTLineAddLogEntry(SuiteCode: Code[10]; CodeunitId: Integer; Description: Text; "Orig. Operation": Text; "Orig. ExecutionSuccess": Boolean; "Orig. Message": Text; var Operation: Text; var ExecutionSuccess: Boolean; var Message: Text)
begin
end;
}
Loading