Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/shouldly/shouldly
Should testing for .NET—the way assertions should be!
https://github.com/shouldly/shouldly
assertion should testing unit
Last synced: 24 days ago
JSON representation
Should testing for .NET—the way assertions should be!
- Host: GitHub
- URL: https://github.com/shouldly/shouldly
- Owner: shouldly
- License: other
- Created: 2010-08-23T07:50:00.000Z (about 14 years ago)
- Default Branch: master
- Last Pushed: 2024-03-06T02:58:19.000Z (8 months ago)
- Last Synced: 2024-04-13T21:00:45.880Z (7 months ago)
- Topics: assertion, should, testing, unit
- Language: C#
- Homepage: https://docs.shouldly.org
- Size: 23.2 MB
- Stars: 1,971
- Watchers: 60
- Forks: 376
- Open Issues: 76
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE.txt
Awesome Lists containing this project
- awesome-for-beginners - Shouldly - In)_ <br> Should testing for .NET - the way Asserting Should be! (.NET)
- fucking-awesome-for-beginners - Shouldly - In)_ <br> Should testing for .NET - the way Asserting Should be! (.NET)
README
![Shouldly Logo](https://raw.githubusercontent.com/shouldly/shouldly/master/assets/logo_350x84.png)
========[![CI](https://github.com/shouldly/shouldly/actions/workflows/CI.yml/badge.svg?branch=master)](https://github.com/shouldly/shouldly/actions/workflows/CI.yml)
[![NuGet](https://img.shields.io/nuget/dt/shouldly.svg)](https://www.nuget.org/packages/Shouldly)
[![NuGet](https://img.shields.io/nuget/vpre/shouldly.svg)](https://www.nuget.org/packages/Shouldly)
[![Join the chat at https://gitter.im/shouldly/shouldly](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/shouldly/shouldly?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)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:
```cs
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:
```cs
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:
```cs
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](https://www.nuget.org/packages/Shouldly/) 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).
```bash
Install-Package Shouldly
```Alternatively if you're using .NET Core then you can install Shouldly via the command line interface with the following command:
```bash
dotnet add package Shouldly
```## Contributing
Contributions to Shouldly are very welcome. For guidance, please see [CONTRIBUTING.md](CONTRIBUTING.md)## Pre-requisites 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
- [Jake Ginnivan](https://github.com/JakeGinnivan)
- [Joseph Woodward](https://github.com/JosephWoodward)If you are interested in helping out, jump on [Gitter](https://gitter.im/shouldly/shouldly) and have a chat.
## Brought to you by
- Dave Newman
- Xerxes Battiwalla
- Anthony Egerton
- Peter van der Woude
- Jake Ginnivan