如果时间戳是周末,即星期六或星期日,我有一个小方法返回真或假。
现在我对单元测试非常陌生,我正在尝试为此编写单元测试。
在我的测试用例中,我将如何进行:
这是我的初步想法。
1. Pick any 1 week from the past and then...
1.1. Get a timestamp for all 5 week days (mon through fri) and pass each timestamp to the function being tested. If they all return false then proceed...
1.2 Get the timestamp for both weekend days and pass each to function being tested. If they both return true then we know the function is correct.
或者
2 Simply pick 1 weekday from the past and 1 weekend day from the past and test with only those 2 dates
我在这两种方法中是否正确,还是有更好的方法来测试它?