In this post we will discuss how to handle multiple assert in Selenium with Assert.multiple of NUnit 3.6, this is one of the most requested feature of NUnit.
Nunit 3.6 released by Jan 9th 2017 has number of notable improvement and features something like this
- .NET Standard 1.6 is now supported
- Adds support for Multiple Assert blocks
- Added the –params option to NUnitLite
- Theories now support Nullable enums
- Improved assert error messages to help differentiate differences in values
- Added warnings with Warn.If(), Warn.Unless() and Assert.Warn()
- Enabled Path, File and Directory Asserts/Contraints for .NET Core testing
- Added NonTestAssemblyAttribute for use by third-party developers to indicate that their assemblies reference the NUnit framework, but do not contain tests
Where is Assert.Multiple helpful ?
Consider a scenario something like this
Lets say we have to test multiple properties of an UI element in Selenium
In Nunit test framework, if the first assert fails (not meeting the condition), then the second assertion will not even takes place and the whole test fails (which we all know)
But using new Assert.Multiple method, the code can be written something like this