I have medium level experience on unit testing and now I'm learning about NUnit.
As far as I can see, a NUnit test passes by default if you don't call Assert.Fail method.
In my test case, I want it to fail by default unless I call Assert.Pass method.
How can I do that if it's possible?
Simplified Example
Current behavior:
// This test passes
public void Test1()
{
}
// This test fails
public void Test1()
{
Assert.Fail();
}
The behavior I want:
// This test must fail
public void Test1()
{
}
// This test must pass
public void Test1()
{
Assert.Pass();
}
Detailed Example for curious cats
The last line of this test looks unnecessary to me. I would like to remove Assert.Fail() call at the end if it was possible to mark the test as "fail by default" somehow. Maybe a parameter for [Test] attribute???
[Test]
public void SetValue_RaisesChangedEvent()
{
var Property = new Property();
Property.Changed += (Sender, Args) => Assert.Pass();
Property.SetValue(1);
Assert.Fail();
}