Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Snapshot Testing

Snapshot Testing

Slides van Michel Schep bij devCampNoord

devNetNoord

April 06, 2023
Tweet

More Decks by devNetNoord

Other Decks in Programming

Transcript

  1. • Intro snapshot testing • Demo (show me the code!)

    • Summary • And then time for questions About this session (Snapshot Testing with Verify)
  2. Demo • Verify (Snapshooter, Snapper, Polaroider, etc) • xUnit (maar

    ook voor MSTest, Nunit) • Rider (VS 2022) • WinMerge • Basic example • Scrubbers • EF Core • Logging • Web API (integration test)
  3. Demo • Martin Fowler • Complex object • Scrubbers •

    EF Core • Loggers • Integration Test • Tools • [UsesVerify] • return Verify(actual) • verified vs received files • .gitignore • Scrub datetime and Guids • Ignore Field • Record EF Core stream • Record Logging stream • HTTP extention
  4. • Snapshot testing is a different way of asserting the

    test results • Very easy to be up and running • Keep the snapshots simple • Verify is a library that implements the snapshot ideas • Verify is extensible (HTTP, Logging, SQL Server, EF Core, Scrubbers) • If a simple assert is possible then use a simple assert (with for example Fluent Assertions) • When possible, replace it by dedicated unit tests • Especially handy when the software works (customers are happy) but no tests and some refactoring is needed Summary