Desidero un TestMethod per più eccezioni. Il problema è che il metodo Test si interrompe dopo la prima eccezione generata.UnitTest ExpectedException con più eccezioni
so che posso fare qualcosa di simile:
try
{
sAbc.ToInteger();
Assert.Fail(); // If it gets to this line, no exception was thrown
}
catch (ArgumentException) { }
ma voglio utilizzare il seguente codice-base:
[TestMethod, ExpectedException(typeof(ArgumentException), "...")]
public void StringToIntException()
{
sAbc.ToInteger(); // throws an exception and stops here
sDecimal.ToInteger(); // throws theoretically a exception too...
}
E non voglio creare una TestMethod per ogni possibile eccezione del genere:
[TestMethod, ExpectedException(typeof(ArgumentException), "...")]
public void StringToIntException()
{
sAbc.ToInteger();
}
[TestMethod, ExpectedException(typeof(ArgumentException), "...")]
public void StringToIntException()
{
sDecimal.ToInteger();
}
come su o di tipo più eccezioni? solo una eccezione accadrà alla volta. Questo è raggiungibile da parte di Mstest? – liang