test(fuzz): FsCheck property tests + continuous-fuzz workflow (#170) - #274
Merged
Conversation
Closes #170. Adds FsCheck.Xunit 2.16.6 (xunit-v2 compatible) and two property sets: 1. `PropertyTests.cs` — 6 properties at default 100 iters each, runs in the PR gate (~250 ms). Covers Try.Run success/failure, generic value round-trip, AllSucceeded ⇔ !AnyFailed duality, and Result.Flatten invariants. 2. `FuzzTests.cs` — same properties at MaxTest=100_000, tagged `[Trait("Category", "Fuzz")]`. Excluded from PR runs via `--filter "Category!=Fuzz"` (pr.yaml, both Linux + Windows stages) — kept out of the per-PR budget. Total ~400_000 randomized cases per weekly run. New `fuzz.yaml`: weekly Mondays 04:00 UTC + workflow_dispatch. Runs Category=Fuzz on net10.0, uploads log as artifact, extracts failing seeds + shrunk counter-examples on failure, and auto-files a `bug`-labelled issue with the reproducer. The first fuzz-mode run surfaced a real latent bug — `Try.Run` throws `ArgumentException` when the caught exception's Message is whitespace-only (Result.Failure rejects whitespace). Filed as #273; both property sets skip the whitespace case via a `string.IsNullOrWhiteSpace` guard so the fuzz workflow ships clean, citing #273 in the property comment so the skip is removed once the bug is fixed. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2 tasks
`ThrowIfNull` is net6+. The test project multi-targets net462 through net10.0, so the FuzzTests / PropertyTests properties added in this PR break the build on net462/net472/net48/net481/net5.0. Replaced with `if (x is null) throw new ArgumentNullException(nameof(x));` which works on every TFM. Caught by the full-repo code review run against vNext-preview. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This was referenced Jul 28, 2026
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.
Closes #170. Files #273 (real bug found by first fuzz run).
Summary
FsCheck.Xunit 2.16.6(xunit-v2 compatible line).PropertyTests.cs— 6 short-form properties at defaultMaxTest = 100each. Runs in the PR gate (~250 ms).FuzzTests.cs— same theorems atMaxTest = 100_000, tagged[Trait("Category", "Fuzz")]. Excluded from PR runs via--filter "Category!=Fuzz"(added to both Linux + Windows stages inpr.yaml).fuzz.yaml— weekly Mondays 04:00 UTC +workflow_dispatch. RunsCategory=Fuzzon net10.0, uploads log as artifact, on failure extracts failing seeds + shrunk counter-examples and auto-files abug-labelled issue with the reproducer.Real finding on first run
Fuzz caught a latent bug immediately:
Try.Run(() => throw new X(" "))throwsArgumentException(from insideResult.Failure, which rejects whitespace) instead of returning aFailedResult. Filed as #273. Both property sets currently skip the whitespace case viastring.IsNullOrWhiteSpaceguard with an inline// tracked in #273comment so the fuzz suite ships clean — remove the guard when #273 lands.Local run
dotnet test -f net10.0 --filter Category!=Fuzz→ 97 pass in 1sdotnet test -f net10.0 --filter Category=Fuzz→ 4 pass in 3s (400_000 randomized cases total, minus whitespace skips)Stacked-PR base
Base =
vNext. One of two in this pair (#177 to follow).Protected-file guard
Touches
.github/workflows/pr.yaml+ addsfuzz.yaml→ protected. Expected admin-bypass at merge.Test plan
workflow_dispatch— 4 properties, ~2–5 min total, all passpr.yamlPR runs succeed with theCategory!=Fuzzfilter