Skip to content

fix: inconsistent assertion error message formatting across 86+ files #4867

@thomhurst

Description

@thomhurst

Description

Error messages across the assertion library use inconsistent prefixes, creating a fragmented user experience:

  • StringAssertions.cs:101"found \"{value}\""
  • NullAssertion.cs:51"value is null"
  • CollectionAssertions.cs:35"collection was null"
  • CollectionAssertions.cs:107"value was null"
  • GreaterThanAssertion.cs"value is null" vs "found {value}"
  • BetweenAssertion.cs:81"value is null" vs line 95 "found {value}"

Impact

Inconsistent error messages reduce clarity and create cognitive friction. Users expect similar assertions to provide similarly-formatted feedback.

Suggested Fix

Establish a standard error message format:

  • "found X" for actual values
  • "was null" for null values
  • "threw ExceptionName" for exceptions

Consider creating a helper method like CreateErrorMessage(string actual) to centralize formatting.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions