Shouldly 4.3.0
dotnet add package Shouldly --version 4.3.0
NuGet\Install-Package Shouldly -Version 4.3.0
<PackageReference Include="Shouldly" Version="4.3.0" />
<PackageVersion Include="Shouldly" Version="4.3.0" />
<PackageReference Include="Shouldly" />
paket add Shouldly --version 4.3.0
#r "nuget: Shouldly, 4.3.0"
#:package Shouldly@4.3.0
#addin nuget:?package=Shouldly&version=4.3.0
#tool nuget:?package=Shouldly&version=4.3.0
Shouldly is an assertion framework which focuses on giving great error messages when the assertion fails while being simple and terse.
This is the old Assert way:
Assert.That(contestant.Points, Is.EqualTo(1337));
For your troubles, you get this message, when it fails:
Expected 1337 but was 0
How it Should be:
contestant.Points.ShouldBe(1337);
Which is just syntax, so far, but check out the message when it fails:
contestant.Points should be 1337 but was 0
It might be easy to underestimate how useful this is. Another example, side by side:
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 -1
Shouldly uses the code before the ShouldBe statement to report on errors, which makes diagnosing easier.
Read more about Shouldly and its features at https://docs.shouldly.org/.
Installation
Shouldly can be found here on NuGet and can be installed by copying and pasting the following command into your Package Manager Console within Visual Studio (Tools > NuGet Package Manager > Package Manager Console).
Install-Package Shouldly
Alternatively if you're using .NET Core then you can install Shouldly via the command line interface with the following command:
dotnet add package Shouldly
Contributing
Contributions to Shouldly are very welcome. For guidance, please see CONTRIBUTING.md
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- DiffEngine (>= 11.3.0)
- EmptyFiles (>= 4.4.0)
- Microsoft.CSharp (>= 4.7.0)
-
net8.0
- DiffEngine (>= 11.3.0)
- EmptyFiles (>= 4.4.0)
-
net9.0
- DiffEngine (>= 11.3.0)
- EmptyFiles (>= 4.4.0)
NuGet packages (125)
Showing the top 5 NuGet packages that depend on Shouldly:
| Package | Downloads |
|---|---|
|
CK.Testing
Contains Test Helpers mixin infrastructure. Shouldly is used for assertions. |
|
|
Miru.Testing
Package Description |
|
|
Takenet.MessagingHub.Client.Tester
The tester library for the C# SDK of the Messaging Hub |
|
|
Saucery2
Sourcery for SauceLabs - Unlocking SauceLabs capability. |
|
|
Statiq.Testing
Statiq is a configurable static content generation framework. This library provides utility classes to make testing easier. |
GitHub repositories (330)
Showing the top 20 popular GitHub repositories that depend on Shouldly:
| Repository | Stars |
|---|---|
|
icsharpcode/ILSpy
.NET Decompiler with support for PDB generation, ReadyToRun, Metadata (&more) - cross-platform!
|
|
|
ardalis/CleanArchitecture
Clean Architecture Solution Template: A proven Clean Architecture Template for ASP.NET Core 9
|
|
|
App-vNext/Polly
Polly is a .NET resilience and transient-fault-handling library that allows developers to express policies such as Retry, Circuit Breaker, Timeout, Bulkhead Isolation, and Fallback in a fluent and thread-safe manner. From version 6.0.1, Polly targets .NET Standard 1.1 and 2.0+.
|
|
|
abpframework/abp
Open-source web application framework for ASP.NET Core! Offers an opinionated architecture to build enterprise software solutions with best practices on top of the .NET. Provides the fundamental infrastructure, cross-cutting-concern implementations, startup templates, application modules, UI themes, tooling and documentation.
|
|
|
aspnetboilerplate/aspnetboilerplate
ASP.NET Boilerplate - Web Application Framework
|
|
|
LuckyPennySoftware/MediatR
Simple, unambitious mediator implementation in .NET
|
|
|
spectreconsole/spectre.console
A .NET library that makes it easier to create beautiful console applications.
|
|
|
LuckyPennySoftware/AutoMapper
A convention-based object-object mapper in .NET.
|
|
|
ThreeMammals/Ocelot
.NET API Gateway
|
|
|
serilog/serilog
Simple .NET logging with fully-structured events
|
|
|
dotnetcore/CAP
Distributed transaction solution in micro-service base on eventually consistency, also an eventbus with Outbox pattern
|
|
|
MessagePack-CSharp/MessagePack-CSharp
Extremely Fast MessagePack Serializer for C#(.NET, .NET Core, Unity, Xamarin). / msgpack.org[C#]
|
|
|
graphql-dotnet/graphql-dotnet
GraphQL for .NET
|
|
|
FastEndpoints/FastEndpoints
A light-weight REST API development framework for ASP.NET 8 and newer.
|
|
|
dotnet/msbuild
The Microsoft Build Engine (MSBuild) is the build platform for .NET and Visual Studio.
|
|
|
jasontaylordev/NorthwindTraders
Northwind Traders is a sample application built using ASP.NET Core and Entity Framework Core.
|
|
|
Shane32/QRCoder
A pure C# Open Source QR Code implementation
|
|
|
MapsterMapper/Mapster
A fast, fun and stimulating object to object Mapper
|
|
|
Cysharp/ZLinq
Zero allocation LINQ with LINQ to Span, LINQ to SIMD, and LINQ to Tree (FileSystem, JSON, GameObject, etc.) for all .NET platforms and Unity, Godot.
|
|
|
Code52/carnac
A utility to give some insight into how you use your keyboard
|
| Version | Downloads | Last Updated |
|---|---|---|
| 4.3.0 | 10,548,453 | 1/23/2025 |
| 4.2.1 | 20,690,143 | 4/24/2023 |
| 4.2.0 | 196,488 | 4/15/2023 |
| 4.1.0 | 8,544,823 | 8/24/2022 |
| 4.0.3 | 17,100,117 | 12/17/2020 |
| 4.0.2 | 60,772 | 12/17/2020 |
| 4.0.1 | 940,202 | 11/15/2020 |
| 4.0.0 | 321,962 | 11/9/2020 |
| 4.0.0-beta0004 | 20,973 | 10/16/2020 |
| 4.0.0-beta0003 | 27,684 | 9/21/2020 |
| 4.0.0-beta0002 | 952,959 | 6/14/2019 |
| 4.0.0-beta0001 | 225,674 | 1/11/2019 |
| 4.0.0-beta.5 | 651 | 11/8/2020 |
| 3.0.2 | 14,466,175 | 11/6/2018 |
| 3.0.1 | 885,371 | 9/20/2018 |
| 3.0.0 | 3,188,542 | 1/19/2018 |
| 3.0.0-beta0003 | 73,365 | 8/2/2017 |
| 3.0.0-beta0001 | 3,642 | 7/19/2017 |
| 2.8.3 | 1,397,294 | 6/5/2017 |
| 2.8.2 | 1,476,517 | 8/13/2016 |
| 2.8.1 | 88,893 | 7/23/2016 |
| 2.8.0 | 270,418 | 6/17/2016 |
| 2.7.0 | 236,531 | 4/4/2016 |
| 2.7.0-beta0003 | 3,941 | 2/2/2016 |
| 2.7.0-beta0002 | 2,022 | 1/30/2016 |
| 2.7.0-beta0001 | 2,473 | 1/2/2016 |
| 2.6.0 | 465,101 | 9/6/2015 |
| 2.5.0 | 156,864 | 4/12/2015 |
| 2.4.0 | 78,287 | 1/29/2015 |
| 2.3.1 | 26,587 | 12/15/2014 |
| 2.3.0 | 5,456 | 11/21/2014 |
| 2.2.1 | 9,759 | 10/22/2014 |
| 2.2.0 | 28,353 | 9/8/2014 |
| 2.1.1 | 71,950 | 3/19/2014 |
| 2.1.0 | 5,498 | 3/13/2014 |
| 1.1.1.1 | 270,166 | 4/21/2012 |
| 1.1.1 | 3,922 | 3/9/2012 |
| 1.1.0.6 | 2,270 | 4/21/2012 |
| 1.1.0.4 | 11,133 | 11/18/2011 |
| 1.1.0.3 | 2,321 | 11/15/2011 |
| 1.1.0.2 | 2,344 | 11/15/2011 |
| 1.1.0.1 | 2,407 | 11/3/2011 |
| 1.1.0 | 2,838 | 9/23/2011 |
| 1.0.1.77 | 2,546 | 9/13/2011 |
| 1.0.1.73 | 3,409 | 7/31/2011 |
| 1.0.1.71 | 2,446 | 7/31/2011 |
| 1.0.1.69 | 2,529 | 5/26/2011 |
| 1.0.1.68 | 2,577 | 5/25/2011 |
| 1.0.1.67 | 2,595 | 5/18/2011 |
| 1.0.1.66 | 2,516 | 5/18/2011 |
| 1.0.1.63 | 2,650 | 3/28/2011 |
| 1.0.1.62 | 2,635 | 3/17/2011 |
| 1.0.1.60 | 65,714 | 2/24/2011 |
