Assert.Pass() throwing exception

6.8k Views Asked by At

I have a constructor as follows

public class MyClass
{
   public MyClass()
   {

   }
}

While writing test cases, i used Assert.Pass(). But it throws an exception of type ArguementNullException

2

There are 2 best solutions below

2
On

The SuccessException is a convenience for a test runner. This allows you to pass a test and record an optional message. The better way to approach this is to just let the test finish without throwing any exceptions or recording failed assertions.

More info here: http://www.nunit.org/index.php?p=utilityAsserts&r=2.5

0
On

If you're using NUnit framework,

Assert.Pass<SuccessException>();

when you want to pass a test.