Shouldly reads the expression before ShouldBe so a failed .NET assertion names what was tested
Should testing for .NET—the way assertions should be!
At a glance
- What is it?
- Shouldly is a .NET assertion library built around failure messages. It uses the source code left of the ShouldBe call to say what was compared, and it ships ShouldMatchApproved diffing as a separate package. This page covers the message mechanism, the install paths and the 5.0.0 preview state.
- Who is it for?
- Pick Shouldly when the pain in your test suite is cryptic failure output and you want the failing expression printed for you. Skip it if you need a published comparison with other assertion libraries, since the repository contains none.
- Can I use it commercially?
- Check first. The repository uses a licence we do not classify automatically, so read its LICENSE file before any commercial use.
- Is it still maintained?
- Yes. The repository last received commits 2 days ago.
- What is it written in?
- Mainly C#, according to GitHub's language statistics.
Answers come from the project's GitHub data, last synced on November 25, 2026, and from our analysis. They are not legal advice.
Star history
- shouldly/shouldly3,427 ★ · +1
| Repository | 2026-11-03 | 2026-11-25 |
|---|---|---|
| shouldly/shouldly | 3.4k | 3.4k |
1 Stars in the last 22 days, measured from the daily GitHub snapshot. Compare with other projects
Editorial analysis
The failure message is built from the code before ShouldBe
Shouldly is an assertion framework that focuses on giving great error messages when an assertion fails, while staying simple and terse. The mechanism is stated directly: it uses the code before the ShouldBe statement to report on errors, which makes diagnosing easier.
The project shows the old way and the Shouldly way side by side. The classic form is:
Assert.That(contestant.Points, Is.EqualTo(1337));When it fails, you get Expected 1337 but was 0. The Shouldly form is:
contestant.Points.ShouldBe(1337);and the failure reads contestant.Points should be 1337 but was 0. The first message tells you a number was wrong. The second tells you which property.
The repository description frames it as should testing for .NET, the way assertions should be. The language is C#, and the project documentation lives at docs.shouldly.org.
A second example shows a method call rendered inside the message
A single property name is an easy case. The README adds a harder one, a lookup on a map:
Assert.That(map.IndexOfValue("boo"), Is.EqualTo(2)); // -> Expected 2 but was -1
map.IndexOfValue("boo").ShouldBe(2); // -> map.IndexOfValue("boo") should be 2 but was -1The classic assertion reports Expected 2 but was -1. A reader with a test log and no source open cannot tell which call returned -1. The Shouldly message includes map.IndexOfValue("boo"), the full expression.
The project says it might be easy to underestimate how useful this is. The practical gain shows up in CI logs, where a failure is read without opening the test file.
The flip side: the message is only as informative as the expression. A value passed through a long chain or a helper gives the message of that chain, and a variable named result still reports result.
Two install paths, one for Visual Studio and one for the dotnet CLI
Shouldly is published on NuGet. In Visual Studio, the instructions say to paste a command into the Package Manager Console, found under Tools, NuGet Package Manager:
Install-Package ShouldlyFor .NET Core, install from the command line instead:
dotnet add package ShouldlyThe two commands do the same job and differ in where you run them. The Package Manager Console command only works inside Visual Studio, so a CI agent or a developer on another editor uses the dotnet form.
The repository root includes Shouldly.sln, global.json and build.ps1, so building from source is a PowerShell script plus an SDK pinned in global.json. A badge links to a Gitter chat room, and contributions are directed to CONTRIBUTING.md.
ShouldMatchApproved needs a second package to show a diff
ShouldMatchApproved is a Shouldly feature for comparing output against an approved file. Showing a diff of the expected and actual files is not built in. To get it, install the Shouldly.DiffEngine package and configure it.
Install-Package Shouldly.DiffEngineShouldMatchConfiguration.ShouldMatchApprovedDefaults.ConfigureDiffEngine();The consequence is easy to miss: a project that uses ShouldMatchApproved but skips this package still fails when output differs, but nothing opens a diff, and you compare the files by hand. The configuration call has to run before the tests that use it.
The visible README does not say which diff tools are launched or how they are chosen, so that detail sits in the documentation site.
The newest tags are 5.0.0 previews and BREAKING CHANGES.txt tracks the cost
The recent releases are 5.0.0-preview.2 on 2026-10-01, 5.0.0-preview.1 on 2026-06-14, and 4.3.0 on 2025-01-23. The most recent stable tag in that list is 4.3.0, and both newer ones carry a preview label.
The repository holds a file called BREAKING CHANGES.txt at the root. A major version bump from 4 to 5 is the situation that file exists for, and anyone planning to move should read it before updating a package reference.
A sensible policy for a team already on 4.3.0 is to stay there until a stable 5.0.0 appears, and to try the preview on a branch. A preview package can change between preview.1 and preview.2 without notice, and a test project that restores whatever is newest could break on a build agent with no code change.
The last push to the repository was on 2026-09-23, and it is not archived.
GitHub reports no license even though LICENSE.txt exists
The repository lists its license as NOASSERTION, which is what GitHub shows when it cannot match the license text to a known identifier. A LICENSE.txt file sits in the root listing, so a license text is present, but the identifier is unresolved.
For a team with a legal review step for dependencies, that is the first thing to read. Open LICENSE.txt and record the terms yourself instead of copying whatever a package scanner reports. The NuGet page is linked from the README badges and may show its own license field.
The repository also contains a documentation folder, a .gitbook.yaml file and assets, which fits the hosted documentation at docs.shouldly.org. The README itself keeps the feature tour short and sends readers there for everything beyond the first two examples.
No comparison with other assertion libraries is published in the repository
People searching for this project often look for comparisons, such as Shouldly against FluentAssertions, against xUnit assertions, or alongside Moq. The repository contains no such comparison. Its only contrast is with the classic Assert.That form.
That sets a limit on what can be claimed. Whether Shouldly is faster, has a larger vocabulary of assertions, or produces better messages than another library is not something the project documents, so any such claim needs your own trial on your own tests.
A fair evaluation takes one failing test from your suite, writes it with ShouldBe, and reads the output next to what you have today. If the expression printed is more useful than what you see now, the switch pays for itself. If your assertions are mostly on local variables with clear names, the gain is smaller.
Editorial conclusion
Pick Shouldly when the pain in your test suite is cryptic failure output and you want the failing expression printed for you. Skip it if you need a published comparison with other assertion libraries, since the repository contains none. Check the LICENSE.txt file and the 5.0.0 preview notes before moving a production test project, because GitHub reports no recognized license and the newest tags are previews.
Frequently asked questions
what is shouldly
Shouldly is an assertion framework for .NET that focuses on giving great error messages when an assertion fails while being simple and terse. It uses the code before the ShouldBe statement to report on errors.
shouldly vs assert
The classic form Assert.That(contestant.Points, Is.EqualTo(1337)) fails with Expected 1337 but was 0. The Shouldly form contestant.Points.ShouldBe(1337) fails with contestant.Points should be 1337 but was 0.
How do I install Shouldly in a .NET project?
Run Install-Package Shouldly in the Visual Studio Package Manager Console, or dotnet add package Shouldly from the command line. ShouldMatchApproved diffs additionally need the Shouldly.DiffEngine package.
Official sources
Add this badge to your README
If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.
[](https://hysenlabs.com/projects/shouldly-shouldly)Star history chart for your README
[](https://hysenlabs.com/projects/shouldly-shouldly)Was this useful?