when I run the following example with the debugger in Visual Studio 2010 (using TestDriven.NET), I get a pass, but when I run it with the ReSharper test runner, I get a fail. The test is written with Microsoft's test framework.
How can I set this up right? I basically just want to call a method with illegal input and I expect it to throw an exception.
[ExpectedException(typeof(System.Exception))]
[TestMethod]
public void TestSomething()
{
throw new System.Exception();
}
Change it to use a less generic Exception (i.e, not System.Exception)
[ExpectedException(typeof(UnauthorizedAccessException))]
[TestMethod]
public void TestSomething()
{
throw new UnauthorizedAccessException();
}
ReSharper seems to not handle ExpectedException with System.Exception that well, which in a way is good. Be specific about your exceptions.
Also, be sure to include the right version of Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With