Shouldly
  • Overview
  • Contributing
  • Documentation
    • Getting Started
    • Configuration
    • Equality
      • ShouldBe
      • NotBe
      • Null
      • Bool
      • Flags
      • AssignableTo
      • OfType
      • OneOf
      • Greater/Less Than
      • InRange
      • MatchApproved
      • Enumerable
      • SameAs
      • String
      • ExampleClasses
    • String
      • ShouldBe
      • Match
      • Contain
      • Null and Empty
      • StartWith
      • EndWith
    • Enumerable
      • ShouldBe
      • All
      • Empty
      • OneOf
      • Contain
      • Unique
      • SubsetOf
      • Have
    • Dictionary
      • ContainKey
      • ContainKeyAndValue
    • Exceptions
      • Throw
      • NotThrow
    • SatisfyAllConditions
    • CompleteIn
    • DynamicShould
    • Upgrade 3 to 4
Powered by GitBook
On this page
  • Installation
  • Contributing
  • Prerequisites for running on build server
  • Currently maintained by
  • Brought to you by
Edit on GitHub

Overview

NextContributing

Last updated 3 months ago

Shouldly Logo

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.

Installation

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

Prerequisites for running on build server

Shouldly uses the source code to make its error messages better. Hence, on the build server you will need to have the "full" pdb files available where the tests are being run.

What is meant by "full" is that when you set up your "release" configuration in Visual Studio and you go to Project Properties > Build > Advanced > Debug, you should set it to "full" rather than "pdb-only".

Currently maintained by

Brought to you by

  • Dave Newman

  • Xerxes Battiwalla

  • Anthony Egerton

  • Peter van der Woude

  • Jake Ginnivan

Shouldly can be and can be installed by copying and pasting the following command into your .

Contributions to Shouldly are very welcome. For guidance, please see

If you are interested in helping out, jump on and have a chat.

found here on NuGet
Package Manager Console within Visual Studio
CONTRIBUTING.md
Jake Ginnivan
Joseph Woodward
Gitter