Usage of Assert.Inconclusive
- by Johannes Rudolph
Hi,
Im wondering how someone should use Assert.Inconclusive().
I'm using it if my Unit test would be about to fail for a reason other than what it is for.
E.g. i have a method on a class that calculates the sum of an array of ints. On the same class there is also a method to calculate the average of the element. It is implemented by calling sum and dividing it by the length of the array.
Writing a Unit test for Sum() is simple.
However, when i write a test for Average() and Sum() fails, Average() is likely to fail also.
The failure of Average is not explicit about the reason it failed, it failed for a reason other than what it should test for.
That's why i would check if Sum() returns the correct result, otherwise i Assert.Inconclusive().
Is this to be considered good practice? What is Assert.Inconclusive intended for? Or should i rather solve the previous example by means of an Isolation Framework?