Skip to content

Commit 4a7b7f9

Browse files
Agents - Introduce new Yaml structure (#7863)
#### Summary Introduce new Yaml structure for Agent tests and bugfixes #### Work Item(s) Fixes [AB#582122](https://dynamicssmb2.visualstudio.com/1fcb79e7-ab07-432a-a3c6-6cf5a88ba4a5/_workitems/edit/582122)
1 parent be9828a commit 4a7b7f9

5 files changed

Lines changed: 61 additions & 5 deletions

File tree

src/Tools/AI Test Toolkit/src/AITTestContext.Codeunit.al

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,27 @@ codeunit 149044 "AIT Test Context"
3939
end;
4040

4141
/// <summary>
42-
/// Get the Test Setup from the input dataset for the current iteration.
42+
/// Get the turn setup from the input dataset for the current iteration.
43+
/// </summary>
44+
/// <returns>A Test Input Json codeunit for the turn_setup element.</returns>
45+
procedure GetTurnSetup(): Codeunit "Test Input Json"
46+
begin
47+
exit(AITTestContextImpl.GetTurnSetup());
48+
end;
49+
50+
/// <summary>
51+
/// Tries to get the turn setup from the input dataset for the current iteration.
52+
/// </summary>
53+
/// <param name="TurnSetup">Returns the turn_setup Test Input Json codeunit when the element exists.</param>
54+
/// <returns>True if the turn_setup element exists for the current turn; false otherwise.</returns>
55+
procedure GetTurnSetup(var TurnSetup: Codeunit "Test Input Json"): Boolean
56+
begin
57+
exit(AITTestContextImpl.GetTurnSetup(TurnSetup));
58+
end;
59+
60+
/// <summary>
61+
/// Get the Test Setup from the input dataset for the current iteration using the legacy 'test_setup' element.
62+
/// Retained for backward compatibility with datasets that have not migrated to 'turn_setup' — new code should use <see cref="GetTurnSetup"/>.
4363
/// </summary>
4464
/// <returns>A Test Input Json codeunit for the test_setup element.</returns>
4565
procedure GetTestSetup(): Codeunit "Test Input Json"

src/Tools/AI Test Toolkit/src/AITTestContextImpl.Codeunit.al

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ codeunit 149043 "AIT Test Context Impl."
3333
ContinueOnFailureTok: Label 'continue_on_failure', Locked = true;
3434
TestMetricsTok: Label 'test_metrics', Locked = true;
3535
TestSetupTok: Label 'test_setup', Locked = true;
36+
TurnSetupTok: Label 'turn_setup', Locked = true;
3637
QuestionTok: Label 'question', Locked = true;
3738
TurnsTok: Label 'turns', Locked = true;
3839
MessagesTok: Label 'messages', Locked = true;
@@ -43,6 +44,7 @@ codeunit 149043 "AIT Test Context Impl."
4344
ConversationTok: Label 'conversation', Locked = true;
4445
HasSuiteSetupData: Boolean;
4546
SuiteSetupDataNotLoadedErr: Label 'Per-suite setup data has not been loaded.';
47+
TurnSetupNotFoundErr: Label 'The turn_setup element was not found for the current turn.';
4648
SuiteSetupInputCodeTok: Label 'SUITE-SETUP', Locked = true;
4749

4850
/// <summary>
@@ -58,6 +60,35 @@ codeunit 149043 "AIT Test Context Impl."
5860

5961
/// <summary>
6062
/// Get the Test Setup from the input dataset for the current iteration.
63+
/// Errors if the turn_setup element is not found for the current turn.
64+
/// </summary>
65+
/// <returns>A Test Input Json codeunit for the turn_setup element.</returns>
66+
procedure GetTurnSetup(): Codeunit "Test Input Json"
67+
var
68+
TurnSetup: Codeunit "Test Input Json";
69+
begin
70+
if not GetTurnSetup(TurnSetup) then
71+
Error(TurnSetupNotFoundErr);
72+
exit(TurnSetup);
73+
end;
74+
75+
/// <summary>
76+
/// Tries to get the Turn Setup from the input dataset for the current iteration.
77+
/// </summary>
78+
/// <param name="TurnSetup">Returns the turn_setup Test Input Json codeunit when the element exists.</param>
79+
/// <returns>True if the turn_setup element exists for the current turn; false otherwise.</returns>
80+
procedure GetTurnSetup(var TurnSetup: Codeunit "Test Input Json"): Boolean
81+
var
82+
ElementFound: Boolean;
83+
begin
84+
TurnSetup := GetTestInput(TurnSetupTok, ElementFound);
85+
exit(ElementFound);
86+
end;
87+
88+
/// <summary>
89+
/// Get the Test Setup from the input dataset for the current iteration using the legacy 'test_setup' element.
90+
/// Errors if the test_setup element is not found for the current turn.
91+
/// Retained for backward compatibility with datasets that have not migrated to 'turn_setup'.
6192
/// </summary>
6293
/// <returns>A Test Input Json codeunit for the test_setup element.</returns>
6394
procedure GetTestSetup(): Codeunit "Test Input Json"

src/Tools/AI Test Toolkit/src/TestSuite/AITALTestSuiteMgt.Codeunit.al

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ using System.Utilities;
1212
codeunit 149037 "AIT AL Test Suite Mgt"
1313
{
1414
Permissions = tabledata "Test Method Line" = rmid,
15-
tabledata "AL Test Suite" = rmid;
15+
tabledata "AL Test Suite" = rmid,
16+
tabledata "Test Input" = rmid,
17+
tabledata "Test Input Group" = rmid;
1618

1719
var
1820
RunProcedureOperationTok: Label 'Run Procedure', Locked = true;

src/Tools/AI Test Toolkit/src/TestSuite/AITTestSuite.Page.al

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -563,11 +563,12 @@ page 149031 "AIT Test Suite"
563563

564564
if CurrentSuiteCode = '' then begin
565565
AITTestSuite.Copy(Rec);
566-
AITTestSuite.FindFirst();
566+
if not (AITTestSuite.FindFirst()) then
567+
exit;
567568
CurrentSuiteCode := AITTestSuite.Code;
568569
end;
569570

570-
Rec.Get(CurrentSuiteCode);
571+
if Rec.Get(CurrentSuiteCode) then;
571572
end;
572573

573574
local procedure ChangeTestSuite()

src/Tools/AI Test Toolkit/src/TestSuite/AITTestSuiteMgt.Codeunit.al

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ using System.Utilities;
1313
codeunit 149034 "AIT Test Suite Mgt."
1414
{
1515
Access = Internal;
16+
Permissions = tabledata "Test Input Group" = rmid,
17+
tabledata "Test Input" = rmid;
1618

1719
var
1820
GlobalAITTestSuite: Record "AIT Test Suite";
@@ -124,7 +126,7 @@ codeunit 149034 "AIT Test Suite Mgt."
124126

125127
AITTestRunInputHandler.SetInput(AITLogEntry."Test Input Group Code", AITLogEntry."Test Input Code");
126128

127-
BindSubscription(AITTestRunInputHandler);
129+
if BindSubscription(AITTestRunInputHandler) then;
128130
RunAITestLine(AITTestMethodLineForLogEntry, false);
129131
UnbindSubscription(AITTestRunInputHandler);
130132

0 commit comments

Comments
 (0)