When running MSTEST unit tests in debug mode, the execution stops in every expected exception that is thrown. My test looks like this
[TestMethod()]
[ExpectedException(typeof(ArgumentNullException))]
public void ShouldThrowExceptionWhenPassingNull()
{
object data = null;
target.CheckNull(data);
}
the target method looks like this:
public void CheckNull(object data)
{
if (ReferenceEquals(null, data))
{
throw new ArgumentNullException("data");
}
} // test run breaks here: ArgumentNullException was unhandled by user code
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…