【发布时间】:2009-12-18 13:01:30
【问题描述】:
我有一个单元测试失败,因为 System.ArgumentException 被抛出,即使我期待它并且这是故意的行为 - 我错过了什么?
[Test]
[ExpectedException(typeof(ArgumentException), ExpectedMessage = "Seconds from midnight cannot be more than 86400 in 010100712386401000000012")]
public void TestParsingCustomReferenceWithInValidSecondsFromMidnight()
{
// I am expecting this method to throw an ArgumentException:
CustomReference.Parse("010100712386401000000012");
}
我也尝试过不设置 ExpectedMessage - 没有区别。
【问题讨论】:
标签: c# unit-testing exception nunit