Usage of Assert.Inconclusive

Posted by Johannes Rudolph on Stack Overflow See other posts from Stack Overflow or by Johannes Rudolph
Published on 2009-08-02T17:01:38Z Indexed on 2010/05/04 19:48 UTC
Read the original article Hit count: 282

Filed under:
|
|
|
|

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?

© Stack Overflow or respective owner

Related posts about TDD

Related posts about best-practices