📜 ⬆️ ⬇️

.NET and Unit Testing: TestCaseAttribute (NUnit 2.5)

Looking at the official NUnit website, I found an interesting novelty in version 2.5 of this wonderful library.

Testing methods on various input data has become very convenient:

[TestCase (12, 3, 4)]
[TestCase (12, 2, 6)]
[TestCase (12, 4, 3)]
[TestCase (12, 0, 0, ExpectedException = typeof (System.DivideByZeroException),
TestName = “DivisionByZeroThrowsExceptionType”)]
[TestCase (12, 0, 0, ExpectedExceptionName = “System.DivideByZeroException”,
TestName = “DivisionByZeroThrowsNamedException”)]
public void IntegerDivisionWithResultPassedToTest (int n, int d, int q)
{
Assert.AreEqual (q, n / d);
}
')
Unfortunately, if you run tests through resharper, this functionality is not for you. For now, this only works if you run the tests directly via NUnit itself (console or gui).

official documentation

Source: https://habr.com/ru/post/54246/


All Articles