When you are working on unit tests, there are scenarios where you wished that the execution should have stopped but alas, the most important part, ‘The Assertion,’ was missed. While developing tests using different test frameworks, my fellow developers frequently asked one question: ‘Should I use an assert or an exception in my test code’? It depends on what the test code should do after a certain condition is met.
By the end of this article, you will get in-depth insights about NUnit asserts and how these asserts can be used with C# & Selenium. I will walk you through the Assertions’ basics and when assertions should be used to get started. We will be covering the following constraints (discussed later) used with NUnit assert:
- Equal Constraints
- Comparison Constraints
- String Constraints
- Condition Constraints
- Collection Constraints
If you already know the constraints, you can head straight to the sections (NUnit Asserts – In Action and NUnit…