Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot find Assert.Fail and Assert.Pass or equivalent

Tags:

.net

xunit.net

I used to use these in NUnit and they are really useful. Any idea how to do something like that?

EDIT, CODE SAMPLE:

        bool condition = false;//would be nice not to have this         observable.Subscribe(_ =>         {             if (real test)                 condition= true;//Assert.Pass()         });         StartObservable();         Assert.True(condition);//Assert.Fail()       
like image 566
naeron84 Avatar asked Jan 31 '13 17:01

naeron84


People also ask

What happens if Assert is failed?

If the suit variable takes on another value and assertions are enabled, the assert will fail and an AssertionError will be thrown.

What is Assert pass?

Pass. The Assert. Pass method allows you to immediately end the test, recording it as successful. Since it causes an exception to be thrown, it is more efficient to simply allow the test to return.


1 Answers

The documentation includes a comparison chart including this:

Fail - xUnit.net alternative: Assert.True(false, "message")

(It doesn't show Assert.Pass, and I've never used that myself, but I suspect the alternative is just to return from the test. Of course that doesn't help if you want to throw it in a nested method call. My suspicion is that it's not very frequently used in NUnit, hence its absence in the comparison chart.)

like image 109
Jon Skeet Avatar answered Sep 21 '22 10:09

Jon Skeet