Unit Test Assertions made easy using Shouldly

Anup MarwadiSoftwareLeave a Comment

Shouldly Example in Unit Tests for C#

Assertions in Unit Testing are often cumbersome to write. Majority of our TDD code is full of Assertions to ensure that Unit Tests meet the criteria specified in the business rules.

Here’s a typical example of a Unit Test using good ol’ Assert.

If you think this is boring, you’re not alone. Not only is it cumbersome, it doesn’t flow free with the way things are supposed to work.

But, there’s a solution. And that is called ‘Shouldly‘. With Shouldly, you no longer have to worry about writing boring TDD Assertions. Programming just got way better. Here’s a great example of how we use Shouldly in our Test Driven Development Environments when building custom Software.

Shouldly is very rich in vocabulary and will make TDD a whole lot of fun and easily readable. Enjoy!

Leave a Reply

Your email address will not be published. Required fields are marked *