I am testing DoingSomething()
method with the following test method-
[TestMethod()]
[ExpectedException(typeof(ArgumentException),"Invalid currency.")]
public void ConvertCurrencyTest_ExhangeRate()
{
try
{
DoingSomething();
}
catch (ArgumentException Ex)
{
}
catch (Exception Ex)
{
Assert.Fail();
}
}
Test result says that DoingSomething()
did not throw an exception. But it thrown exception indeed.
What did I miss here?
You are consuming the exception in your try/catch so it is not bubbling up to be caught by the test.
Remove the try/catch
and let the test harness handle the exception. Any other exception would naturally cause the test to fail anyway.
[TestMethod()]
[ExpectedException(typeof(ArgumentException),"Invalid currency.")]
public void ConvertCurrencyTest_ExhangeRate() {
DoingSomething();
}
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