Adopt the Any test helpers across the unit-test suites#160
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adopt the
Anytest helpers (fromFirstClassErrors.Testing, introduced in #135) across the core and request-binder unit-test suites: incidental values are drawn fromAnywhile every value a test actually asserts stays an explicit literal. The effect is that each test pins only what it verifies.Type of change
Changes
ErrorCodeFactory.CreateAny()(fixed"ANY") and the nestedErrorMessageFactory.CreateAnyMessage()(fixed"boom"); route their call sites throughAny.ErrorCode()/Any.DiagnosticMessage()and deleteErrorCodeFactory.ToString, projected through a fold, serialized, or compared — with the matchingAny.*helper: error codes, diagnostic/short/detailed messages,Transience/InteractionDirection/ErrorOrigin, ints, and incidental context strings..WithMessage("boom")/"ko:boom"cases), theErrorCode.UnspecifiedandTransience.Unknowncases whose identity or aggregation is checked,nullsubjects, and trimming inputs.Any.Transience()/Any.InteractionDirection()— which never returnUnknown— are used only where the enum value is unobserved.ErrorContextKey(noAnyequivalent by design) and documentation-content assertions.Testing
dotnet build FirstClassErrors.slndotnet test FirstClassErrors.slnFirstClassErrors.Analyzers.UnitTests)Because
Anyis non-deterministic by default, the two affected suites were additionally run five times to exercise different draws; every run was green (FirstClassErrors.UnitTests423/423,FirstClassErrors.RequestBinder.UnitTests62/62). Each conversion was also reviewed against its test's assertions to confirm the value is genuinely unobserved.Documentation
doc/updateddoc/README.fr.md) updated if user-facing behavior changedTest-only change: no public API and no user-facing behavior is affected.
Architecture decisions
Proposed: ADR-____This change applies the decision already recorded in ADR-0006 (the
Anyarbitrary-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