is there a MsTest Equivalent of Assert.Warning in MbUnit ?
There are some complexities to this which will come in another blog post, but the result is we can now use the following syntax to assert an exception in MSTest: Assert. Throws(() => sc. Add("-1"));
In your unit test case, you can use a try-catch block. Let me show you what I mean. You use the try block to execute the code under test. If the method throws an exception, that will be covered by the catch block.
The assert section ensures that the code behaves as expected. Assertions replace us humans in checking that the software does what it should. They express requirements that the unit under test is expected to meet. Now, often one can write slightly different assertions to capture a given requirement.
The closest match is Assert.Inconclusive()
- it doesn't make the test fail as such, but it doesn't succeed either. It fall into a third stage called Inconclusive.
A single Inconclusive test will cause an entire test suite to be Inconclusive.
There are overloads that supports custom messages as well:
Assert.Inconclusive("Ploeh");
I have a similar issue as I use NUnit for some projects. Try using
Console.Write("Some Warning");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With