Quiero un TestMethod para múltiples excepciones. El problema es que el Método de prueba se detiene después de la primera excepción lanzada.UnitTest ExpectedException with multiple Exceptions
sé que puedo hacer algo así:
try
{
sAbc.ToInteger();
Assert.Fail(); // If it gets to this line, no exception was thrown
}
catch (ArgumentException) { }
Pero quiero usar el siguiente código base:
[TestMethod, ExpectedException(typeof(ArgumentException), "...")]
public void StringToIntException()
{
sAbc.ToInteger(); // throws an exception and stops here
sDecimal.ToInteger(); // throws theoretically a exception too...
}
Y no quiero crear uno para TestMethod cada posible excepción como esa:
[TestMethod, ExpectedException(typeof(ArgumentException), "...")]
public void StringToIntException()
{
sAbc.ToInteger();
}
[TestMethod, ExpectedException(typeof(ArgumentException), "...")]
public void StringToIntException()
{
sDecimal.ToInteger();
}
¿qué tal o con conexión a múltiples excepciones? solo una excepción sucederá a la vez. ¿Es esto alcanzable por mstest? – liang