Repository navigation
test: reduce the generator snapshot tests - #1100
Conversation
Every generator special case added thousands of snapshot lines spread over many files (172 files on main), which made generator changes hard to review and the snapshot folder hard to navigate. Union mode only changes the setups and verifications of non-generic methods and indexers without params or ref struct parameters, so scenarios whose special case never reaches that code gain nothing from a union copy. The files that are not specific to a mocked type only differ in the arities or types they cover, so comparing them in a few representative scenarios is enough while every scenario still compiles them. Comparing the files of the mocked types of a scenario as one snapshot lets a special case add one snapshot instead of one per mocked type.
[Low impact] The PR appears safe to merge.
|
There was a problem hiding this comment.
All reported issues were addressed across 175 files
Reply with feedback, questions, or to request a fix.
Turn on auto-fix | Re-trigger cubic
Test Results 58 files ± 0 58 suites ±0 1h 54m 9s ⏱️ - 26m 51s Results for commit 9750eae. ± Comparison against base commit fa69238. This pull request removes 31 and adds 16 tests. Note that renamed tests count towards both. |
🚀 Benchmark ResultsCompared to Memory
Time
CompleteWorkflowBenchmarks
BenchmarkDotNet v0.15.8, Linux Ubuntu 26.04.1 LTS (Resolute Raccoon) AMD EPYC 9V74 3.69GHz, 1 CPU, 4 logical and 2 physical cores .NET SDK 11.0.100 [Host] : .NET 11.0.0 (11.0.0, 11.0.26.53018), X64 RyuJIT x86-64-v4 Job=InProcess Toolchain=InProcessEmitToolchain IterationCount=15 LaunchCount=1 WarmupCount=10 MockCreationBenchmarks
BenchmarkDotNet v0.15.8, Linux Ubuntu 26.04.1 LTS (Resolute Raccoon) AMD EPYC 7763 2.77GHz, 1 CPU, 4 logical and 2 physical cores .NET SDK 11.0.100 [Host] : .NET 11.0.0 (11.0.0, 11.0.26.53018), X64 RyuJIT x86-64-v3 Job=InProcess Toolchain=InProcessEmitToolchain IterationCount=15 LaunchCount=1 WarmupCount=10 CompleteUnconfiguredBenchmarks
BenchmarkDotNet v0.15.8, Linux Ubuntu 26.04.1 LTS (Resolute Raccoon) AMD EPYC 7763 2.75GHz, 1 CPU, 4 logical and 2 physical cores .NET SDK 11.0.100 [Host] : .NET 11.0.0 (11.0.0, 11.0.26.53018), X64 RyuJIT x86-64-v3 Job=InProcess Toolchain=InProcessEmitToolchain IterationCount=15 LaunchCount=1 WarmupCount=10 CompleteMethodBenchmarks
BenchmarkDotNet v0.15.8, Linux Ubuntu 26.04.1 LTS (Resolute Raccoon) Intel Xeon 6975P-C 2.70GHz, 1 CPU, 4 logical and 2 physical cores .NET SDK 11.0.100 [Host] : .NET 11.0.0 (11.0.0, 11.0.26.53018), X64 RyuJIT x86-64-v4 Job=InProcess Toolchain=InProcessEmitToolchain IterationCount=15 LaunchCount=1 WarmupCount=10 CompletePropertyBenchmarks
BenchmarkDotNet v0.15.8, Linux Ubuntu 26.04.1 LTS (Resolute Raccoon) Intel Xeon Platinum 8370C CPU 2.80GHz (Max: 3.41GHz), 1 CPU, 4 logical and 2 physical cores .NET SDK 11.0.100 [Host] : .NET 11.0.0 (11.0.0, 11.0.26.53018), X64 RyuJIT x86-64-v4 Job=InProcess Toolchain=InProcessEmitToolchain IterationCount=15 LaunchCount=1 WarmupCount=10 CompleteIndexerBenchmarks
BenchmarkDotNet v0.15.8, Linux Ubuntu 26.04.1 LTS (Resolute Raccoon) AMD EPYC 9V74 3.68GHz, 1 CPU, 4 logical and 2 physical cores .NET SDK 11.0.100 [Host] : .NET 11.0.0 (11.0.0, 11.0.26.53018), X64 RyuJIT x86-64-v4 Job=InProcess Toolchain=InProcessEmitToolchain IterationCount=15 LaunchCount=1 WarmupCount=10 CompleteEventBenchmarks
BenchmarkDotNet v0.15.8, Linux Ubuntu 26.04.1 LTS (Resolute Raccoon) Intel Xeon 6973P-C 4.20GHz, 1 CPU, 4 logical and 2 physical cores .NET SDK 11.0.100 [Host] : .NET 11.0.0 (11.0.0, 11.0.26.53018), X64 RyuJIT x86-64-v4 Job=InProcess Toolchain=InProcessEmitToolchain IterationCount=15 LaunchCount=1 WarmupCount=10 CallbackBenchmarks
BenchmarkDotNet v0.15.8, Linux Ubuntu 26.04.1 LTS (Resolute Raccoon) AMD EPYC 7763 3.06GHz, 1 CPU, 4 logical and 2 physical cores .NET SDK 11.0.100 [Host] : .NET 11.0.0 (11.0.0, 11.0.26.53018), X64 RyuJIT x86-64-v3 Job=InProcess Toolchain=InProcessEmitToolchain IterationCount=15 LaunchCount=1 WarmupCount=10 AsyncBenchmarks
BenchmarkDotNet v0.15.8, Linux Ubuntu 26.04.1 LTS (Resolute Raccoon) AMD EPYC 7763 2.95GHz, 1 CPU, 4 logical and 2 physical cores .NET SDK 11.0.100 [Host] : .NET 11.0.0 (11.0.0, 11.0.26.53018), X64 RyuJIT x86-64-v3 Job=InProcess Toolchain=InProcessEmitToolchain IterationCount=15 LaunchCount=1 WarmupCount=10 SequenceBenchmarks
BenchmarkDotNet v0.15.8, Linux Ubuntu 26.04.1 LTS (Resolute Raccoon) INTEL XEON PLATINUM 8573C 2.99GHz, 1 CPU, 4 logical and 2 physical cores .NET SDK 11.0.100 [Host] : .NET 11.0.0 (11.0.0, 11.0.26.53018), X64 RyuJIT x86-64-v4 Job=InProcess Toolchain=InProcessEmitToolchain IterationCount=15 LaunchCount=1 WarmupCount=10 |
The special cases in GeneratorCoverage are covered by targeted tests, so their snapshots mostly added diffs that got accepted without review. Their scenarios still check that the generated code compiles without diagnostics under C# 14, with warnings and documentation comments checked, which no other test project does. The union scenarios of EqualsMembers and ObjectLookAlikes come back for that check, as their union output differs from the classic one.
Edge-case scenarios no longer compare snapshots, so a new file that is not specific to a mocked type would go unreviewed if only an edge case generates it.
There was a problem hiding this comment.
All reported issues were addressed across 2 files (changes from recent commits).
Reply with feedback, questions, or to request a fix.
Turn on auto-fix | Re-trigger cubic
|
…ts (#1100) by Valentin Breuß
…ts (#1100) by Valentin Breuß
The special cases do not depend on their own type, so they join an existing coverage type without a snapshot of their own (#1100). Union mode never applies to a method with a same-named sibling, so the sibling check there had no effect.



Every generator special case added thousands of snapshot lines spread over many files, which made generator changes hard to review and the snapshot folder hard to navigate. The special cases in
GeneratorCoverageare already covered by targeted tests (runtime tests inMockolate.TestsandGenerator.Runassertions), so their snapshots mostly added diffs that got accepted without review.The snapshot folder goes from 172 files with about 200,000 lines to 30 files with about 44,000 lines.
What changes
Snapshotcompare the generated files: the comprehensive interface and delegate (also in union mode), a base class with additional interfaces,HttpClient, logging, logger classes, auto-mocking and ref structs.Snapshot, so a new shared file cannot go unreviewed.EqualsMembersandObjectLookAlikeskeep their union scenario, as their union output differs.IOptionalMethodParametersWithSiblingis merged intoIOptionalMethodParametersasWithSibling, following the new rule that a special case only gets its own coverage type when it depends on the type.Docs/agents/workflows.mddescribes when a special case adds a scenario, a_Unionsscenario or its own coverage type.