#280 knowledge(testing): ExpectedError must identify the intended error
The testing knowledge article on assertion errors now clarifies that ExpectedError and ExpectedErrorCode match by substring, and adds guidance to avoid weak verification patterns that cannot distinguish between different errors.
- 1files
- 1AL files
- 0objects
Pull request · merged into main on 2026-11-19 by MichaelDieringer · 1 file (+2 -2), 1 AL · other · tier official · reviewed (checked by Opus)
What changed
- Both ExpectedError and ExpectedErrorCode match by substring
- Best practice asks for text only the intended error produces, ideally the full Label with arguments built with StrSubstNo
- ExpectedErrorCode on its own identifies only the kind of error
- New anti-patterns: ExpectedErrorCode alone, a non-empty GetLastErrorText() check, or a fragment shared by several messages on the same code path
- With these weak checks a test stays green when an earlier validation fires instead of the one under test
AL objects touched
microsoft/knowledge/testing/asserterror-needs-expectederror-and-code.md: modified, not in the BC? snapshot
Context
- Systems: development
Source: metadata of a merged pull request in microsoft/BCQuality (bcquality): title, labels, changed paths and counts, with a summary in our words. No source text and no description beyond one short quote (D10, D61).