Skip to content

test: record the null subject behaviour of every expectation - #1057

Merged
vbreuss merged 1 commit into
mainfrom
test/null-subject-behaviour-sweep
Sep 12, 2026
Merged

vbreuss merged 1 commit into
mainfrom
test/null-subject-behaviour-sweep

Conversation

@vbreuss

@vbreuss vbreuss commented Sep 12, 2026

Copy link
Copy Markdown
Member

GuaranteesNotNullTests only invoked the expectations marked with [GuaranteesNotNull], so the behaviour of every other expectation for a null subject was unrecorded - and it cannot be read off the test suite either, because the null cases hide under four naming conventions and sometimes inside an [InlineData(null)] row.

Sweep all 467 expectation names per subject type instead and assert the rule that a null subject fails, with ExpectationsThatDoNotFail listing today's 140 deviations (159 on net48, which has no generic math).

This changes no behaviour; it is the safety net for the null philosophy of the next major version, where each change deletes entries from that list.

To keep the record truthful, the harness now

  • skips subjects that cannot be null, reusing CanHaveNullSubject,
  • compiles no-op delegates instead of passing null for them,
  • puts one element into collection arguments,
  • tries nullable arguments as both default and null,
  • walks every completion path on a fresh subject, since reusing one expectation makes the second continuation throw and hides the family,
  • and separates "the test cannot build this call" from an expectation that throws, via NotInvocableException.

`GuaranteesNotNullTests` only invoked the expectations marked with
`[GuaranteesNotNull]`, so the behaviour of every other expectation for a
`null` subject was unrecorded - and it cannot be read off the test suite
either, because the null cases hide under four naming conventions and
sometimes inside an `[InlineData(null)]` row.

Sweep all 467 expectation names per subject type instead and assert the
rule that a `null` subject fails, with `ExpectationsThatDoNotFail` listing
today's 140 deviations (159 on `net48`, which has no generic math).

This changes no behaviour; it is the safety net for the `null` philosophy
of the next major version, where each change deletes entries from that list.

To keep the record truthful, the harness now
- skips subjects that cannot be `null`, reusing `CanHaveNullSubject`,
- compiles no-op delegates instead of passing `null` for them,
- puts one element into collection arguments,
- tries nullable arguments as both `default` and `null`,
- walks every completion path on a fresh subject, since reusing one
  expectation makes the second continuation throw and hides the family,
- and separates "the test cannot build this call" from an expectation that
  throws, via `NotInvocableException`.
@vbreuss vbreuss self-assigned this Sep 12, 2026
Copilot AI lite review requested due to automatic review settings September 12, 2026 19:38
@vbreuss vbreuss added the coverage Additional tests for edge cases or improvement of test coverage label Sep 12, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@vbreuss
vbreuss merged commit b40f1a2 into main Sep 12, 2026
10 checks passed
@vbreuss
vbreuss deleted the test/null-subject-behaviour-sweep branch September 12, 2026 19:42
@sonarqubecloud

Copy link
Copy Markdown

github-actions Bot added a commit that referenced this pull request Sep 12, 2026
…ur of every expectation (#1057) by Valentin Breuß
github-actions Bot added a commit that referenced this pull request Sep 12, 2026
…ur of every expectation (#1057) by Valentin Breuß
@github-actions

Copy link
Copy Markdown
Contributor

👽 Mutation Results

Mutation testing badge

aweXpect

Details
File Score Killed Survived Timeout No Coverage Ignored Compile Errors Runtime Errors Total Detected Total Undetected Total Mutants

The final mutation score is NaN%

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

aweXpect.Core

Details
File Score Killed Survived Timeout No Coverage Ignored Compile Errors Runtime Errors Total Detected Total Undetected Total Mutants

The final mutation score is NaN%

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

@github-actions

Copy link
Copy Markdown
Contributor

🚀 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 8.0.31 (8.0.31, 8.0.3126.42015), X64 RyuJIT x86-64-v3

Job=InProcess Toolchain=InProcessEmitToolchain IterationCount=15
LaunchCount=1 WarmupCount=10

Method Mean Error StdDev Gen0 Gen1 Allocated
Bool_aweXpect 242.3 ns 1.94 ns 1.72 ns 0.0415 - 696 B
Bool_FluentAssertions 246.3 ns 0.54 ns 0.48 ns 0.0567 - 952 B
Equivalency_aweXpect 289,276.1 ns 764.32 ns 714.95 ns 20.0195 0.4883 335444 B
Equivalency_FluentAssertions 2,299,742.8 ns 10,049.52 ns 8,391.81 ns 289.0625 46.8750 4841651 B
Int_GreaterThan_aweXpect 249.6 ns 1.01 ns 0.94 ns 0.0515 - 864 B
Int_GreaterThan_FluentAssertions 240.7 ns 0.50 ns 0.42 ns 0.0730 - 1224 B
ItemsCount_AtLeast_aweXpect 451.0 ns 4.90 ns 4.58 ns 0.0811 - 1360 B
ItemsCount_AtLeast_FluentAssertions 470.1 ns 1.69 ns 1.41 ns 0.1197 - 2008 B
String_aweXpect 451.4 ns 1.62 ns 1.43 ns 0.0672 - 1128 B
String_FluentAssertions 1,142.5 ns 7.42 ns 6.57 ns 0.2346 - 3944 B
StringArray_aweXpect 1,862.3 ns 4.99 ns 4.42 ns 0.1564 - 2624 B
StringArray_FluentAssertions 1,300.6 ns 20.93 ns 18.55 ns 0.2480 - 4152 B
StringArrayInAnyOrder_aweXpect 2,529.0 ns 33.49 ns 31.32 ns 0.1678 - 2816 B
StringArrayInAnyOrder_FluentAssertions 20,387.6 ns 286.59 ns 268.08 ns 1.9836 0.0610 33471 B

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

coverage Additional tests for edge cases or improvement of test coverage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants