lundi 27 avril 2015

Fail test if method thorws exception

I'm using ExpectedException, like in this example below, to verify that a test throws an exception.

[Test]
[ExpectedException( typeof( ArgumentException ) )]
public void TestMethod()
{
...
}

Is there any opposite to ExpectedException like UnexpectedException that fails a test if a method throws an exception? I know that I can use try-catch or Assert.DoesNotThrow( TestDelegate code ); but I wonder if the is a simplier solution.

Aucun commentaire:

Enregistrer un commentaire