Hi, I create test codeunits and use them on Business Central Performance Toolkit (on that side everything is fine) but I get these errors when I try to do a pullrequest on Azure DevOps.
Here is the type of error I get :
Codeunit 50195 Create S.O Without WMS Failure (1.749 seconds)
##[error]CreateSaleOrder(,): error : BCPT Code must have a value in BCPT Line: BCPT Code=, Line No.=0. It cannot be zero or empty.
Testfunction CreateSaleOrder Failure (0.23 seconds)
and here is one of my affected codes :
codeunit 50195 "Create S.O Without WMS" implements "BCPT Test Param. Provider"
{
Subtype = Test;
var
BCPTTestContext: Codeunit "BCPT Test Context";
IsInitialised: Boolean;
NoOfLinesParamLbl: Label 'Lines';
ParamValidationErr: Label 'Parameter is not defined in the correct format, the Expected format is "%1"', Comment = '%1 explain format';
NoOfLinesToCreate: integer;
LibrarySales: Codeunit "Library - Sales";
LibraryUtility: Codeunit "Library - Utility";
LibraryRandom: Codeunit "Library - Random";
Libraryssert: Codeunit Assert;
[StrMenuHandler]
procedure StrMenuHandler(Options: Text[1024]; var choice: integer; Instruction: Text[1024])
begin
BCPTTestContext.StartScenario('Choose');
choice := 3;
Commit();
BCPTTestContext.EndScenario('Choose');
BCPTTestContext.UserWait();
end;
[ConfirmHandler]
procedure ConfirmHandler(Quest: Text; var rep: Boolean)
begin
BCPTTestContext.StartScenario('Do not open the PSI');
rep := false;
Commit();
BCPTTestContext.EndScenario('Do not open the PSI');
end;
trigger OnRun();
begin
if not IsInitialised then begin
InitTest();
IsInitialised := true;
end;
end;
[Test]
[HandlerFunctions('StrMenuHandler,ConfirmHandler')]
procedure CreateSaleOrder()
var
Customer: Record Customer;
SaleOrder: TestPage "Sales Order";
Item: record Item;
i: integer;
Location: Record Location;
begin
if not Customer.Get('10000') then Customer.FindFirst();
if not Item.get('70000') then Item.FindFirst();
if not Location.Get('NOWMS1') then Location.FindFirst();
NoOfLinesToCreate := LibraryRandom.RandIntInRange(1, 7);
BCPTTestContext.StartScenario('Add Order');
SaleOrder.OpenNew();
Commit();
BCPTTestContext.EndScenario('Add Order');
BCPTTestContext.UserWait();
BCPTTestContext.StartScenario('Add Account No.');
SaleOrder."Sell-to Customer No.".Value := Customer."No.";
Commit();
BCPTTestContext.EndScenario('Add Account No.');
BCPTTestContext.UserWait();
BCPTTestContext.StartScenario('Add Location');
SaleOrder."Location Code".Value := Location.Code;
Commit();
BCPTTestContext.EndScenario('Add Location');
BCPTTestContext.UserWait();
for i := 1 to NoOfLinesToCreate do begin
BCPTTestContext.StartScenario('Enter Line Item No.');
SaleOrder.SalesLines."No.".Value := Item."No.";
Commit();
BCPTTestContext.EndScenario('Enter Line Item No.');
BCPTTestContext.UserWait();
BCPTTestContext.StartScenario('Enter Line Quantity');
SaleOrder.SalesLines.Quantity.setValue(LibraryRandom.RandIntInRange(1, 50));
Commit();
BCPTTestContext.EndScenario('Enter Line Quantity');
BCPTTestContext.UserWait();
SaleOrder.SalesLines.Next();
end;
BCPTTestContext.StartScenario('Release');
SaleOrder.Release.Invoke();
Commit();
BCPTTestContext.EndScenario('Release');
BCPTTestContext.UserWait();
BCPTTestContext.StartScenario('Post');
SaleOrder.Post.Invoke();
Commit();
BCPTTestContext.EndScenario('Post');
BCPTTestContext.UserWait();
end;
local procedure InitTest()
begin
Commit();
if Evaluate(NoOfLinesToCreate, BCPTTestContext.GetParameter(NoOfLinesParamLbl)) then;
end;
procedure GetDefaultParameters(): Text[1000]
begin
exit(copystr(NoOfLinesParamLbl + '=' + Format(10), 1, 1000));
end;
procedure ValidateParameters(Parameters: Text[1000])
begin
if StrPos(Parameters, NoOfLinesParamLbl) > 0 then begin
Parameters := DelStr(Parameters, 1, StrLen(NoOfLinesParamLbl + '='));
if Evaluate(NoOfLinesToCreate, Parameters) then
exit;
end;
end;
}```