NDC Conferences

.NET Testing Techniques You Didn’t Know You Needed - Dante De Ruwe - NDC Copenhagen 2026

Published 2026-07-08 · Duration 58:44

Summary

This talk explores advanced .NET testing techniques designed to improve test effectiveness and build confidence in code quality beyond basic unit tests. Key methods include Property-Based Testing (PBT) for generating vast input variations, Snapshot Testing for tracking complex output changes over time, and Mutation Testing for verifying if existing tests are actually capable of catching bugs. The speaker emphasizes that the goal is not just to write many tests, but to write fewer, highly effective tests.

Download summary

Key takeaways

  1. Test Reliability vs. Code Trust 2:00

    Tests should be viewed as a 'parachute'—they must have no holes. A failing test when requirements haven't changed indicates a bug; passing when the code changes suggests incomplete coverage or potential issues.

  2. Randomized and Property-Based Testing (PBT) 7:10

    Instead of relying solely on example cases, PBT defines mathematical properties that the code must always satisfy (e.g., a + b = b + a). This is crucial for complex structures or when edge case enumeration is impossible.

  3. Snapshot Testing 13:20

    This technique captures and saves the output of a function (the 'snapshot'). Subsequent test runs fail if the output changes unexpectedly, making it ideal for verifying API contracts (like OpenAPI specs) or complex data structures without writing explicit assertions for every field.

  4. Mutation Testing 26:20

    This advanced technique introduces small bugs (mutations) into the code and checks if the existing test suite fails. A high mutation score indicates that tests are effective at catching subtle errors, debunking false confidence from high line coverage metrics.

Technical details

  • Property-Based Testing (PBT) 430s

    PBT allows defining properties (like commutativity or associativity for addition) rather than specific input/output pairs. Tools like `fscheck` (a .NET package inspired by QuickCheck) facilitate this, generating random parameters to test the code's adherence to mathematical rules.

  • Snapshot Testing / Golden Master Testing 800s

    Used for complex data or API contracts (e.g., OpenAPI specs). The first run saves the output structure; subsequent runs fail if the generated output deviates, ensuring unintended changes are caught without writing exhaustive assertions.

  • Mutation Testing 1580s

    A quality metric that measures test effectiveness by introducing controlled bugs (mutants) into the source code. The 'mutation score' is the percentage of mutants killed by tests; a low score means tests are ineffective, even if coverage is high.

  • Flaky Tests Mitigation 1050s

    To prevent flaky tests, developers should use deterministic test data (by seeding random generators) and employ large sample sizes when running randomized tests. When dealing with time-sensitive code, always work with UTC and use abstractions like `ISystemClock`.

Mentioned resources

  • Bogus (Library)
  • fscheck (Library)
  • Verify (Simon Crop) (Library)
  • Striker (Tool/Library)

Channel & topics

Watch on YouTube · Back to latest

This independent, AI-assisted summary is provided for commentary and informational purposes. It may contain errors or omit important context. Please watch the original video for the creator's complete presentation. Video, thumbnail, and related copyrights belong to their respective owners.