【发布时间】:2016-08-30 21:54:26
【问题描述】:
所以我希望能够在 TestCase 中指定不同的异常消息,但不知道如何完成
这是原版
[Test]
[ExpectedException(typeof(SystemException), ExpectedMessage = "Holiday cannot start or end on a weekend or non-working day")]
public void AddHolidays_StartsInvlaid()
{}
TestCase 就是这样
[TestCase("27/04/2025", "28/05/2025", "FullDay", "FullDay", ExpectedMessage = "Holiday cannot start or end on a weekend or non-working day")]
[ExpectedException(typeof(SystemException), ExpectedMessage)]
public void AddHolidays_Exceptions(string dateFrom, string dateTo, string fromPeriod, string toPeriod)
{}
该方法工作正常,但我只想能够使用 NUnit TestCase 指定异常消息
【问题讨论】:
标签: c# unit-testing exception nunit testcase