---
id: change/bcquality/280
type: change
title: "#280 knowledge(testing): ExpectedError must identify the intended error"
summary: 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.
tier: official
language: en
tags:
  - other
  - main
system: development
review:
  state: reviewed
  by: opus
  at: "2026-11-23T00:56:58.962Z"
  flags: []
generated:
  at: "2026-11-23T00:15:10.597Z"
  pipeline: 0.2.0
  prompts:
    extract-change: 1
  input_hash: b4613eafba00ad35994ef1e7cba1b8b5839a1ed1
evidence:
  - kind: code
    url: https://github.com/microsoft/BCQuality/pull/280
    title: "microsoft/BCQuality#280: knowledge(testing): ExpectedError must identify the intended error"
    date: "2026-11-19"
    commit: b4613eafba00ad35994ef1e7cba1b8b5839a1ed1
    t: null
    quote: null
links:
  learn: []
  objects: []
  features: []
  topics: []
  localizations: []
  videos: []
  posts: []
  guidelines:
    - guideline/microsoft/knowledge/testing/asserterror-needs-expectederror-and-code
  changes: []
number: 280
repo: microsoft/BCQuality
source_id: bcquality-prs
url: https://github.com/microsoft/BCQuality/pull/280
kind: pr
base_branch: main
major: null
merged_at: "2026-11-19T12:17:58Z"
author: MichaelDieringer
author_type: User
community_contribution: false
labels: []
change_class: code
change_kind: other
behavior_change: false
breaking: false
files:
  count: 1
  additions: 2
  deletions: 2
  al: 1
apps: []
objects_touched: []
objects_unjoined:
  - path: microsoft/knowledge/testing/asserterror-needs-expectederror-and-code.md
    status: modified
    reason: not-in-snapshot
obsoletions: []
backports: []
fixes_issues: []
work_items: []
systems:
  - development
quote: null
joined_against:
  major: null
  commit: null
---

# #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.

[Pull request](https://github.com/microsoft/BCQuality/pull/280) · 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`](../../guidelines/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).
