Skip to content

Improve the Syntax Element Assert Helpers - #484

Merged
alexanderlinne merged 2 commits into
mainfrom
improve-fluent-syntex-elements-test-assert-helpers
Aug 28, 2026
Merged

alexanderlinne merged 2 commits into
mainfrom
improve-fluent-syntex-elements-test-assert-helpers

Conversation

@alexanderlinne

Copy link
Copy Markdown
Collaborator

Evaluation results come out in Mono.Cecil loader order, which is deterministic per build but not stable across Cecil or runtime upgrades. Sort the results ordinally when rendering a snapshot so every "Multiple inputs" and "Multiple arguments" block stops depending on that order. The sorted list is also what is handed to ToErrorMessage, so the "Message:" section is stable too; ToErrorMessage itself is production output and stays untouched.

Materialize the evaluation results once in each Assert* method. FormatSnapshot enumerates its argument twice and the All/Any guards add one or two more, so each assertion evaluated its rule up to four times. That is harmless only because every call site currently passes a plain ArchRule, whose Evaluate materializes internally; CombinedArchRule.Evaluate returns a lazy Concat.

AssertOnlyViolations could pass vacuously: ArchRule.Evaluate injects a synthetic failing result when a rule produces no results at all, and the assertion only rejected passing results. A helper lookup that stopped matching would therefore keep the test green. Reject that placeholder unless allowNoResults is set. Only one call site legitimately needs it.

@codecov-commenter

codecov-commenter commented Aug 28, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.50%. Comparing base (34e4211) to head (8fc416c).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #484   +/-   ##
=======================================
  Coverage   82.50%   82.50%           
=======================================
  Files         259      259           
  Lines       12395    12395           
  Branches     1206     1206           
=======================================
  Hits        10226    10226           
  Misses       1798     1798           
  Partials      371      371           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Evaluation results come out in Mono.Cecil loader order, which is deterministic
per build but not stable across Cecil or runtime upgrades. Sort the results
ordinally when rendering a snapshot so every "Multiple inputs" and "Multiple
arguments" block stops depending on that order. The sorted list is also what is
handed to ToErrorMessage, so the "Message:" section is stable too;
ToErrorMessage itself is production output and stays untouched.

Materialize the evaluation results once in each Assert* method. FormatSnapshot
enumerates its argument twice and the All/Any guards add one or two more, so
each assertion evaluated its rule up to four times. That is harmless only
because every call site currently passes a plain ArchRule, whose Evaluate
materializes internally; CombinedArchRule.Evaluate returns a lazy Concat.

AssertOnlyViolations could pass vacuously: ArchRule.Evaluate injects a synthetic
failing result when a rule produces no results at all, and the assertion only
rejected passing results. A helper lookup that stopped matching would therefore
keep the test green. Reject that placeholder unless allowNoResults is set. Only
one call site legitimately needs it.

Signed-off-by: Alexander Linne <alexander.linne@tngtech.com>
@alexanderlinne
alexanderlinne force-pushed the improve-fluent-syntex-elements-test-assert-helpers branch from 84e64b5 to fed9ded Compare August 28, 2026 07:30
@alexanderlinne
alexanderlinne merged commit 6d8fd73 into main Aug 28, 2026
10 checks passed
@alexanderlinne
alexanderlinne deleted the improve-fluent-syntex-elements-test-assert-helpers branch August 28, 2026 08:07
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.

3 participants