Nei*_*ell 4 c# nunit unit-testing exception
我有一个单元测试失败,因为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");
}
Run Code Online (Sandbox Code Playgroud)
我也试过没有ExpectedMessage被设置 - 没有区别.
你试过断言语法吗?
Assert.Throws<ArgumentException>(
() => CustomReference.Parse("010100712386401000000012"),
"Seconds from midnight cannot be more than 86400 in 010100712386401000000012"
);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3136 次 |
| 最近记录: |