4 AL/BC testing patterns from an external BC testing expert's blog (Luc van Vugt, fluxxus.nl) - #159
Conversation
Fourth batch from CURABIS ApS, mined from an external BC/NAV testing expert's blog archive (fluxxus.nl). Confirm+StrSubstNo interaction with ConfirmHandler, Table Relation Test's OnAfterRemoveTableRelation exclusion hook (verified against BCApps source, codeunit 134926), committing shared lazy-Initialize fixture data, and Assert.IsFalse vs asserterror for boolean checks.
|
Michael Dieringer (@MichaelDieringer) please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.
Contributor License AgreementContribution License AgreementThis Contribution License Agreement (“Agreement”) is agreed to by the party signing below (“You”),
|
2 similar comments
|
Michael Dieringer (@MichaelDieringer) please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.
Contributor License AgreementContribution License AgreementThis Contribution License Agreement (“Agreement”) is agreed to by the party signing below (“You”),
|
|
Michael Dieringer (@MichaelDieringer) please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.
Contributor License AgreementContribution License AgreementThis Contribution License Agreement (“Agreement”) is agreed to by the party signing below (“You”),
|
Summary
Fourth batch from CURABIS ApS, this time mined from a source outside CURABIS itself: Luc van Vugt's fluxxus.nl, a long-running blog by a BC/NAV developer who authored a book on automated testing and ATDD in Business Central. The blog runs 2009–2023 and is mostly legacy classic-client/C-AL content; these 4 are the patterns that survived a full read-through, are still current in modern AL, and cleared BCQuality's admission test.
Confirm()+StrSubstNo: a[ConfirmHandler]'sQuestionparameter receives the raw, unsubstituted template whenConfirmis called with its own placeholder-substitution overload — the production code must build the string withStrSubstNofirst for a handler-side assertion to see the real message.OnAfterRemoveTableRelationexclusion hook — verified directly against BCApps source (codeunit 134926 "Table Relation Test",src/Layers/W1/Tests/Misc/TableRelationTest.Codeunit.al) rather than taken on the blog's word alone.Initialize()fixture data needs an explicitCommit(), or it rolls back with the first test that creates it and silently vanishes for every test after.Assert.IsFalsefor a boolean check, notasserterrorwrapped aroundAssert.IsTrue—asserterrorverifies that an error was raised, not the value under test.Two other candidates found during mining were rejected: a
TestPermissions::InheritFromTestCodeunitenum-value restriction (too thin/overlapping the existing permission-tests rule) and a suite-wide fixture-injection event pattern from 2018/2020 NAV content that no longer exists anywhere in current BCApps source (verified absent, not proposed).Test plan
🤖 Generated with Claude Code