Skip to content

Adopt the Any test helpers across the unit-test suites#160

Merged
Reefact merged 3 commits into
mainfrom
claude/first-class-errors-any-tests-n5d3n5
Jul 16, 2026
Merged

Adopt the Any test helpers across the unit-test suites#160
Reefact merged 3 commits into
mainfrom
claude/first-class-errors-any-tests-n5d3n5

Conversation

@Reefact

@Reefact Reefact commented Jul 16, 2026

Copy link
Copy Markdown
Owner

Summary

Adopt the Any test helpers (from FirstClassErrors.Testing, introduced in #135) across the core and request-binder unit-test suites: incidental values are drawn from Any while every value a test actually asserts stays an explicit literal. The effect is that each test pins only what it verifies.

Type of change

  • Bug fix
  • New feature
  • Breaking change
  • Refactoring
  • Analyzer / diagnostic change
  • Tests
  • Documentation
  • Build / CI / tooling

Changes

  • Remove the redundant "any value" test factories ErrorCodeFactory.CreateAny() (fixed "ANY") and the nested ErrorMessageFactory.CreateAnyMessage() (fixed "boom"); route their call sites through Any.ErrorCode() / Any.DiagnosticMessage() and delete ErrorCodeFactory.
  • Case by case across 19 files (125 conversions), replace every value a test never observes — never asserted, rendered via ToString, projected through a fold, serialized, or compared — with the matching Any.* helper: error codes, diagnostic/short/detailed messages, Transience / InteractionDirection / ErrorOrigin, ints, and incidental context strings.
  • Preserve every observed value and load-bearing sentinel: asserted codes and messages (including the .WithMessage("boom") / "ko:boom" cases), the ErrorCode.Unspecified and Transience.Unknown cases whose identity or aggregation is checked, null subjects, and trimming inputs. Any.Transience() / Any.InteractionDirection() — which never return Unknown — are used only where the enum value is unobserved.
  • Out of scope, left untouched: ErrorContextKey (no Any equivalent by design) and documentation-content assertions.

Testing

  • dotnet build FirstClassErrors.sln
  • dotnet test FirstClassErrors.sln
  • Analyzer tests pass (FirstClassErrors.Analyzers.UnitTests)

Because Any is non-deterministic by default, the two affected suites were additionally run five times to exercise different draws; every run was green (FirstClassErrors.UnitTests 423/423, FirstClassErrors.RequestBinder.UnitTests 62/62). Each conversion was also reviewed against its test's assertions to confirm the value is genuinely unobserved.

Documentation

  • Public API / error documentation updated
  • README / doc/ updated
  • French translation (doc/README.fr.md) updated if user-facing behavior changed
  • No documentation change required

Test-only change: no public API and no user-facing behavior is affected.

Architecture decisions

  • No architectural decision in this pull request
  • New decision recorded — ADR drafted as Proposed: ADR-____
  • Supersedes an existing ADR — successor proposed, status not flipped: ADR-____
  • ⚠️ Conflicts with an existing ADR — flagged for the maintainer: ADR-____

This change applies the decision already recorded in ADR-0006 (the Any arbitrary-value source); it introduces no new lasting decision.

Related issues

Closes #143

🤖 Generated with Claude Code

https://claude.ai/code/session_01WbomxAk3C16dTBjvTjpc3o


Generated by Claude Code

claude and others added 3 commits July 16, 2026 07:02
Replace the ad-hoc ErrorCodeFactory.CreateAny() (fixed "ANY") and the
nested ErrorMessageFactory.CreateAnyMessage() (fixed "boom") with the
Any.ErrorCode() / Any.DiagnosticMessage() helpers from
FirstClassErrors.Testing, and delete the now-redundant factories.

These values are incidental to the tests that use them, so drawing them
from Any states their arbitrariness and removes fixed-constant
overfitting. Asserted literals are left untouched.

Refs: #143

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WbomxAk3C16dTBjvTjpc3o
Extend the Any adoption case by case across the core and request-binder
test suites: for every error / outcome / error-code / enum construction,
values the test never observes (never asserted, rendered, projected,
serialized, or compared) are drawn from the matching Any.* helper, while
every observed literal is kept explicit. This makes each test pin only
what it verifies.

Observed values and load-bearing sentinels are preserved: asserted codes
and messages, the ErrorCode.Unspecified and Transience.Unknown cases whose
identity/aggregation is checked, null subjects, and trimming inputs. The
never-Unknown Any.Transience()/Any.InteractionDirection() are used only
where the enum value is unobserved.

Verified adversarially per file, then the suites were run five times to
exercise the non-deterministic draws; all green.

Refs: #143

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WbomxAk3C16dTBjvTjpc3o
@Reefact Reefact enabled auto-merge July 16, 2026 08:36
@Reefact Reefact disabled auto-merge July 16, 2026 11:04
@Reefact Reefact merged commit 0ad5870 into main Jul 16, 2026
11 of 16 checks passed
@Reefact Reefact deleted the claude/first-class-errors-any-tests-n5d3n5 branch July 16, 2026 11:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Adopt the Any test helpers across our unit tests where they improve them

2 participants