Make NUnit not stop on first crash

I am running a NUnit test on a list of numbers.

My code looks something like this:

numbers = GetListOfNumbers()
foreach number in numbers
      Assert.IsTrue(TestNumber(number))

My problem is that NUnit will stop the test at the first number it encounters, which fails the test.

In any case, so that NUnit still doesn't check if any numbers fail, but give me a list of all the numbers that fail?

+3
source share
3 answers

As a workaround, instead of using Assert.IsTrue, you can try something like:

numbers = GetListOfNumbers()
List<number> fails = numbers.Where(currentNum=>!TestNumber(curentNum))
if (fails.Count > 0)
    Assert.Fail(/*Do whatever with list of fails*/)
+7
source

NUnit 2.5 , ; , . .

+6

This can be done in MBUnit using the "RowTest" test method. However, I do not know how to do this in NUnit.

0
source

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


All Articles