Skip to content

fix: follow the message conventions and call all caller predicates through UserCode - #387

Merged
vbreuss merged 3 commits into
mainfrom
fix/message-conventions
Oct 10, 2026
Merged

vbreuss merged 3 commits into
mainfrom
fix/message-conventions

Conversation

@vbreuss

@vbreuss vbreuss commented Oct 10, 2026

Copy link
Copy Markdown
Member

Some failure messages did not follow aweXpect's message conventions — two negated texts even stated the opposite of what is checked — and several predicates of the caller could still escape the evaluation.

Changes

  • Negated HasNamespace reads "has namespace not equal to …" instead of the double negation "does not have namespace not equal to …", and the negated ThatAssemblies.DependOn text no longer states the opposite of the check
  • Names, namespaces and target frameworks are reported as members: "but it had name "PublicProperty", which differs …"
  • Type relations format the actual type like the expected one (ThatType.UnrelatedClass instead of the full CLR name) and no longer repeat the expectation in the result
  • The remaining predicates of the caller (Which, Except, WithVersion, attribute predicates, parameter and generic-argument filters) run through UserCode.Invoke, so a throwing predicate fails the expectation ("… the predicate did throw …")

@vbreuss vbreuss self-assigned this Oct 10, 2026
@vbreuss
vbreuss added this pull request to stack #389 October 10, 2026 08:33
Base automatically changed from fix/user-code-and-arguments to main October 10, 2026 08:51
…like core (#386)

 throwing predicate, name selector, Contains* filter or custom dependency resolver aborted the evaluation instead of failing the expectation (and its negation), missing arguments surfaced as NullReferenceExceptions, argument exceptions bypassed the trace writer and used wording that differs from aweXpect.Core, and ContainsMethods ignored the cancellation of the evaluation.
…ations

A negated namespace or dependency expectation was negated twice ("does not have namespace not equal to …"), so it read as the opposite of what was checked; a mismatching name, namespace or target framework was reported as "it was …" without naming the member; and the type-relation results repeated the expectation while their Actual context bypassed the formatting settings.
When a Which, Except, WithVersion or attribute predicate of a filter, or a predicate added to the parameter or generic argument filter options, threw during the evaluation, the failure did not name the predicate as the code that threw.
@vbreuss
vbreuss force-pushed the fix/message-conventions branch from 993c8df to e95263e Compare October 10, 2026 08:51
@sonarqubecloud

Copy link
Copy Markdown

@github-actions

Copy link
Copy Markdown

Test Results

    13 files  ±  0      13 suites  ±0   13m 1s ⏱️ + 3m 2s
 6 972 tests + 30   6 969 ✅ + 30   3 💤 ±0  0 ❌ ±0 
41 677 runs  +180  41 664 ✅ +180  13 💤 ±0  0 ❌ ±0 

Results for commit e95263e. ± Comparison against base commit 3b33b91.

@github-actions

Copy link
Copy Markdown

🚀 Benchmark Results

Details

BenchmarkDotNet v0.15.8, Linux Ubuntu 24.04.5 LTS (Noble Numbat)
AMD EPYC 9V74 2.87GHz, 1 CPU, 4 logical and 2 physical cores
.NET SDK 10.0.303
[Host] : .NET 10.0.12 (10.0.12, 10.0.1226.42308), X64 RyuJIT x86-64-v3
DefaultJob : .NET 10.0.12 (10.0.12, 10.0.1226.42308), X64 RyuJIT x86-64-v3

Method Mean Error StdDev Gen0 Allocated
TypeIsNotStatic_aweXpect 131.1 ns 0.48 ns 0.43 ns 0.0248 416 B

@github-actions

Copy link
Copy Markdown

👽 Mutation Results

Mutation testing badge

aweXpect.Reflection

Details
File Score Killed Survived Timeout No Coverage Ignored Compile Errors Runtime Errors Total Detected Total Undetected Total Mutants
Filters/AssemblyFilters.Except.cs 100.00% 3 0 0 0 0 0 0 3 0 3
Filters/AssemblyFilters.Which.cs 100.00% 2 0 0 0 0 0 0 2 0 2
Filters/AssemblyFilters.WithVersion.cs 100.00% 26 0 0 0 3 5 0 26 0 34
Filters/ConstructorFilters.Except.cs 100.00% 3 0 0 0 0 0 0 3 0 3
Filters/ConstructorFilters.Which.cs 100.00% 2 0 0 0 0 0 0 2 0 2
Filters/EventFilters.Except.cs 100.00% 3 0 0 0 0 0 0 3 0 3
Filters/EventFilters.Which.cs 100.00% 2 0 0 0 0 0 0 2 0 2
Filters/FieldFilters.Except.cs 100.00% 3 0 0 0 0 0 0 3 0 3
Filters/FieldFilters.Which.cs 100.00% 2 0 0 0 0 0 0 2 0 2
Filters/MethodFilters.Except.cs 100.00% 3 0 0 0 0 0 0 3 0 3
Filters/MethodFilters.Which.cs 100.00% 2 0 0 0 0 0 0 2 0 2
Filters/PropertyFilters.Except.cs 100.00% 3 0 0 0 0 0 0 3 0 3
Filters/PropertyFilters.Which.cs 100.00% 2 0 0 0 0 0 0 2 0 2
Filters/TypeFilters.Except.cs 100.00% 5 0 0 0 0 0 0 5 0 5
Filters/TypeFilters.Which.cs 100.00% 2 0 0 0 0 0 0 2 0 2
Helpers/AssemblyHelpers.cs 91.94% 57 3 0 2 12 5 0 57 5 79
Helpers/ConstructorInfoHelpers.cs 100.00% 28 0 0 0 11 2 0 28 0 41
Helpers/EventInfoHelpers.cs 100.00% 21 0 0 0 4 2 0 21 0 27
Helpers/FieldInfoHelpers.cs 97.22% 35 1 0 0 12 2 0 35 1 50
Helpers/MethodInfoHelpers.cs 80.51% 95 14 0 9 38 4 0 95 23 160
Helpers/PropertyInfoHelpers.cs 98.51% 66 1 0 0 6 4 0 66 1 77
Helpers/TypeHelpers.cs 77.37% 482 80 0 61 201 64 0 482 141 888
Options/GenericArgumentFilterOptions.cs 72.73% 8 0 0 3 6 2 0 8 3 19
Options/GenericArgumentsFilterOptions.cs 91.18% 31 2 0 1 13 7 0 31 3 54
Options/ParameterFilterOptions.cs 84.00% 21 3 0 1 10 4 0 21 4 39
ThatAssemblies.DependOn.cs 70.00% 7 0 0 3 0 8 0 7 3 18
ThatAssembly.HasName.cs 100.00% 5 0 0 0 1 3 0 5 0 9
ThatAssembly.Targets.cs 100.00% 5 0 0 0 1 3 0 5 0 9
ThatMember.HasName.cs 100.00% 5 0 0 0 1 3 0 5 0 9
ThatType.HasNamespace.cs 100.00% 5 0 0 0 1 3 0 5 0 9
ThatType.Implements.cs 100.00% 27 0 0 0 7 8 0 27 0 42
ThatType.InheritsFrom.cs 100.00% 28 0 0 0 9 10 0 28 0 47
ThatType.IsAssignableTo.cs 100.00% 30 0 0 0 14 16 0 30 0 60

The final mutation score is 84.70%

Coverage Thresholds: high:80 low:60 break:0

@vbreuss
vbreuss merged commit 5a51793 into main Oct 10, 2026
16 checks passed
@vbreuss
vbreuss deleted the fix/message-conventions branch October 10, 2026 10:22
@github-actions

Copy link
Copy Markdown

This is addressed in release v3.0.0.

@github-actions github-actions Bot added the state: released The issue is released label Oct 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

state: released The issue is released

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant