Assertion framework for .NET unit tests that keeps syntax terse and surfaces readable errors using the expression before each ShouldBe call.
Overview
Shouldly is a .NET assertion library aimed at unit and integration tests. It wraps common expectations in fluent ShouldBe-style calls that stay short in test code while producing failure messages that mirror the calling expression.
When an assertion fails, messages include the subject from the code leading up to the call (for example reporting contestant.Points should be expected but was actual), which the project contrasts with classic Assert APIs that only show raw expected versus actual values.
The package is distributed on NuGet for Visual Studio Package Manager Console installs and for .NET SDK command-line adds. Optional ShouldMatchApproved workflows can show file diffs when used with the Shouldly.DiffEngine companion package.
On build servers, richer messages rely on full PDB debug symbols in release builds where tests execute, not pdb-only output, so CI environments need those symbols available for optimal diagnostics.
Key features
- Fluent ShouldBe assertions
- Expression-aware error messages
- NuGet distribution
- Visual Studio and dotnet CLI install
- ShouldMatchApproved file comparisons
- DiffEngine integration for approvals
Use cases
- .NET unit test assertions
- Clearer CI test failure diagnostics
- Approval-style file comparison tests