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
26 changes: 23 additions & 3 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,20 @@
var
BCPTLogEntry: Record "BCPT Log Entry";
BCPTRoleWrapperImpl: Codeunit "BCPT Role Wrapper"; // single instance
ValuesAreChanged: Boolean;

Check failure on line 167 in src/Tools/Performance Toolkit/App/src/BCPTLine.Codeunit.al

View workflow job for this annotation

GitHub Actions / Build Performance Toolkit (Clean) / Performance Toolkit (Clean)

AA0137 Variable 'ValuesAreChanged' is unused in 'AddLogEntry'.

Check failure on line 167 in src/Tools/Performance Toolkit/App/src/BCPTLine.Codeunit.al

View workflow job for this annotation

GitHub Actions / Build Performance Toolkit (Default) / Performance Toolkit (Default)

AA0137 Variable 'ValuesAreChanged' is unused in 'AddLogEntry'.
BCPTTestSuite: Codeunit "BCPT Test Suite";

Check failure on line 168 in src/Tools/Performance Toolkit/App/src/BCPTLine.Codeunit.al

View workflow job for this annotation

GitHub Actions / Build Performance Toolkit (Clean) / Performance Toolkit (Clean)

AA0021 Variable declarations should be ordered by type. Variables should be sorted like this: Record, Report, Codeunit, XmlPort, Page, Query, Notification, BigText, DateFormula, RecordId, RecordRef, FieldRef, and FilterPageBuilder. The rest of the variables are not sorted.

Check failure on line 168 in src/Tools/Performance Toolkit/App/src/BCPTLine.Codeunit.al

View workflow job for this annotation

GitHub Actions / Build Performance Toolkit (Default) / Performance Toolkit (Default)

AA0021 Variable declarations should be ordered by type. Variables should be sorted like this: Record, Report, Codeunit, XmlPort, Page, Query, Notification, BigText, DateFormula, RecordId, RecordRef, FieldRef, and FilterPageBuilder. The rest of the variables are not sorted.
ModifiedOperation: Text;
ModifiedExecutionSuccess: Boolean;
ModifiedMessage: Text;
EntryWasModified: Boolean;
begin
ModifiedOperation := Operation;
ModifiedExecutionSuccess := ExecutionSuccess;
ModifiedMessage := Message;
BCPTTestSuite.OnBeforeBCPTLineAddLogEntry(BCPTLine."BCPT Code", BCPTLine."Codeunit ID", BCPTLine.Description, Operation, ExecutionSuccess, Message, ModifiedOperation, ModifiedExecutionSuccess, ModifiedMessage);
if (Operation <> ModifiedOperation) or (ExecutionSuccess <> ModifiedExecutionSuccess) or (Message <> ModifiedMessage) then
EntryWasModified := true;

BCPTLine.Testfield("BCPT Code");
BCPTRoleWrapperImpl.GetBCPTHeader(BCPTHeader);
Clear(BCPTLogEntry);
Expand All @@ -173,18 +186,25 @@
BCPTLogEntry."BCPT Line No." := BCPTLine."Line No.";
BCPTLogEntry.Version := BCPTHeader.Version;
BCPTLogEntry."Codeunit ID" := BCPTLine."Codeunit ID";
BCPTLogEntry.Operation := copystr(Operation, 1, MaxStrLen(BCPTLogEntry.Operation));
BCPTLogEntry.Operation := CopyStr(ModifiedOperation, 1, MaxStrLen(BCPTLogEntry.Operation));
BCPTLogEntry."Orig. Operation" := CopyStr(Operation, 1, MaxStrLen(BCPTLogEntry."Orig. Operation"));
BCPTLogEntry.Tag := BCPTRoleWrapperImpl.GetBCPTHeaderTag();
BCPTLogEntry."Entry No." := 0;
BCPTLogEntry."Test Company Name" := BCPTHeader."Test Company Name";
if ExecutionSuccess then
if ModifiedExecutionSuccess then
BCPTLogEntry.Status := BCPTLogEntry.Status::Success
else begin
BCPTLogEntry.Status := BCPTLogEntry.Status::Error;
BCPTLogEntry."Error Call Stack" := CopyStr(GetLastErrorCallStack, 1, MaxStrLen(BCPTLogEntry."Error Call Stack"));
end;
if ExecutionSuccess then
BCPTLogEntry."Orig. Status" := BCPTLogEntry.Status::Success
else
BCPTLogEntry."Orig. Status" := BCPTLogEntry.Status::Error;
BCPTLogEntry.Message := CopyStr(ModifiedMessage, 1, MaxStrLen(BCPTLogEntry.Message));
BCPTLogEntry."Orig. Message" := CopyStr(Message, 1, MaxStrLen(BCPTLogEntry."Orig. Message"));
BCPTLogEntry."Log was Modified" := EntryWasModified;
BCPTLogEntry."No. of SQL Statements" := NumSQLStatements;
BCPTLogEntry.Message := copystr(Message, 1, MaxStrLen(BCPTLogEntry.Message));
BCPTLogEntry."End Time" := EndTime;
BCPTLogEntry."Start Time" := StartTime;
BCPTLogEntry."Duration (ms)" := BCPTLogEntry."End Time" - BCPTLogEntry."Start Time";
Expand Down
28 changes: 27 additions & 1 deletion src/Tools/Performance Toolkit/App/src/BCPTLogEntries.Page.al
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,25 @@ page 149003 "BCPT Log Entries"
ToolTip = 'Specifies the single operation of the BCPT.';
ApplicationArea = All;
}
field("Orig. Operation"; Rec."Orig. Operation")
{
ToolTip = 'Specifies the original operation of the BCPT.';
Visible = false;
ApplicationArea = All;
}
field(Message; Rec.Message)
{
Caption = 'Message';
ToolTip = 'Specifies when the message from the test.';
ApplicationArea = All;
}
field("Orig. Message"; Rec."Orig. Message")
{
Caption = 'Orig. Message';
Visible = false;
ToolTip = 'Specifies the original message from the test.';
ApplicationArea = All;
}
field(DurationMin; Rec."Duration (ms)")
{
Caption = 'Duration (ms)';
Expand All @@ -110,6 +123,13 @@ page 149003 "BCPT Log Entries"
ToolTip = 'Specifies the status of the iteration.';
ApplicationArea = All;
}
field("Orig. Status"; Rec."Orig. Status")
{
Caption = 'Orig. Status';
Visible = false;
ToolTip = 'Specifies the original status of the iteration.';
ApplicationArea = All;
}
field("Error Call Stack"; Rec."Error Call Stack")
{
Caption = 'Call stack';
Expand All @@ -121,7 +141,13 @@ page 149003 "BCPT Log Entries"
Message(Rec."Error Call Stack");
end;
}

field("Log was Modified"; Rec."Log was Modified")
{
Caption = 'Log was Modified';
ToolTip = 'Specifies if the log was modified by any event subscribers.';
Visible = false;
ApplicationArea = All;
}
}
}
}
Expand Down
26 changes: 26 additions & 0 deletions src/Tools/Performance Toolkit/App/src/BCPTLogEntry.Table.al
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,32 @@ table 149002 "BCPT Log Entry"
DataClassification = SystemMetadata;
Caption = 'RunID';
}
field(20; "Orig. Operation"; Text[100])
{
Caption = 'Orig. Operation';
}
/// <summary>
/// Contains the original status of the test if any event subscribers modifies the status of the test
/// </summary>
field(21; "Orig. Status"; Option)
{
Caption = 'Orig. Status';
OptionMembers = Success,Error;
}
/// <summary>
/// Contains the original message of the test if any event subscribers modifies the message of the test
/// </summary>
field(22; "Orig. Message"; Text[250])
{
Caption = 'Orig. Message';
}
/// <summary>
/// Is true if any event subscribers has modified the log entry
/// </summary>
field(23; "Log was Modified"; Boolean)
{
Caption = 'Log was Modified';
}
}

keys
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