【发布时间】:2016-01-13 22:42:47
【问题描述】:
考虑以下测试:
[TestCase(2016, true)]
[TestCase(2017, false)]
[TestCase(2018, false)]
[TestCase(2019, false)]
[TestCase(2020, true)]
public void When_IsLeapYear_ReturnTrueForLeapYear(int year, bool expectedResult)
{
//Act
var result = _sut.IsLeapYear(year);
//Assert
Assert.AreEqual(result, expectedResult);
}
在这样的测试用例中同时包含年份和预期结果是一种不好的做法,而不是创建两个不同的测试(例如,一个用于预期为真,一个用于预期为假?)
谢谢
【问题讨论】:
标签: unit-testing testing tdd nunit