0

I have a unit test, something like this:

[Test]
[Row(1)]
[Row(2)]
[Row(3)] //This value is expected to fail
public void Test_MyMethod(int value)
{
    Assert.IsTrue(MyMethod(value));
}

Okay, this is an extremely simple test, but, assume MyMethod returns False when value is 3. Is there a way to tell MbUnit that Row(3) will fail, and hence, pass the test. Of course, I want it to fail if the test doesn't fail.. makes sense?

I can just write out another method that tests for failure with Assert.IsFalse but just wondering if I can achieve the same thing in the same function.

thanks

LocustHorde
  • 6,361
  • 16
  • 65
  • 94
  • 1
    You can pass the expected result as a second parameter. – Preston Guillot Dec 16 '14 at 16:25
  • @PrestonGuillot is there a documentation somewhere I can look up? Can't find anything on it – LocustHorde Dec 16 '14 at 16:29
  • 1
    I'm not familiar with MbUnit's row/column oriented testing paradigm enough to know, but for NUnit style testing (which should work directly with xUnit, and possibly MbUnit as well), given your example code, I'd just use `TestCase` and add a second paramter: http://nunit.org/index.php?p=testCase&r=2.5 – Preston Guillot Dec 16 '14 at 16:35
  • @PrestonGuillot Can you add your comment as an answer? I finally ended up doing an `expectedResult` param to go with the main parameter and it worked well enough. If you make that an answer, I'll be happy to accept it! thanks. – LocustHorde Mar 19 '15 at 19:28

0 Answers0