bcquality/community/knowledge/testing/handlerfunctions-attribute-must-match-ui-path.good.al
Jesper Schulz-Wedde 6c02d68b4e Add testing knowledge: UI handlers, table relations, asserterror, fixtures (P1+P2)
Six BC-specific testing-domain knowledge articles in community/knowledge/testing/, each with .good.al/.bad.al samples:

- ui-calls-require-test-handlers
- tablerelation-requires-prerequisite-records
- handlers-enqueue-never-assert
- handlerfunctions-attribute-must-match-ui-path
- asserterror-needs-expectederror-and-code
- use-library-codeunits-for-test-fixtures

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-06-29 16:10:17 +02:00

34 lines
916 B
AL

codeunit 50406 "Test Handler Match Good"
{
Subtype = Test;
[Test]
[HandlerFunctions('ConfirmHandlerYes,PostMessageHandler')]
procedure PostWithConfirmAndMessage()
begin
// The path below raises BOTH a Confirm and a Message, and the
// attribute names exactly those two handlers — no more, no less.
RunPostingThatConfirmsAndMessages();
end;
local procedure RunPostingThatConfirmsAndMessages()
begin
if Confirm('Post this document?', false) then
Message('Posting completed.');
end;
[ConfirmHandler]
procedure ConfirmHandlerYes(Question: Text; var Reply: Boolean)
begin
Reply := true;
end;
[MessageHandler]
procedure PostMessageHandler(Message: Text)
begin
LibraryVariableStorage.Enqueue(Message);
end;
var
LibraryVariableStorage: Codeunit "Library - Variable Storage";
}