question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Using Should for unit test assertions

See original GitHub issue

I’ve been contributing to this project writing some unit tests and I was wondering if we would be interested in using the Should assertion library.

I love using Should and I find myself missing it greatly when writing tests in the old Assert.Equal(expectation, actual) way.

The library allows you to use extension methods to make your assertions. The syntax is actual.ShouldEqual(expectation). This eliminates the need to remember the order of the arguments in the assertion. It also allows you to use intellisense to find assertions for the type that you are testing easily.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:9 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
tonysurmacommented, Mar 1, 2017

let’s keep with Shouldly as it is current in our codebase as you said @stevejgordon

0reactions
stevejgordoncommented, Mar 1, 2017

@tonysurma We have Shoudly in place already and it’s used it a fair number of tests, therefore I would propose we stick with that so we have a single library in use. I’ve used both and the differences seem to be negligible.

If you’re happy, I would propose we close this?

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to write better unit test assertions
The first two sections exercise the code on some relevant scenario. The assert section ensures that the code behaves as expected. Assertions ......
Read more >
Best Practices for Assertions in Unit Tests
1. The Unit Test Does Not Include an Assertion ... The first, and most egregious, is when we write a unit test without...
Read more >
Stop requiring only one assertion per unit test
There's nothing wrong with multiple assertions in a single test. The above example illustrates the benefits. A single test case can have ...
Read more >
Are asserts or unit tests more important?
The main differences are that asserts function as sanity checks and see real inputs, whereas unit tests run on specific simulated inputs and...
Read more >
Unit Testing Tutorial: 6 Best Practices to Get Up To Speed
It asserts the hypothesis itself. Asserting something represents the essence of testing.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found