我有两个测试方法
[TestMethod]
[ExpectedException(typeof(ArgumentException))]
public void testNotADate()
{
prepareNewTest();
excelex.addTimeToDict("testProject", "Not a Date", "Not a Time");
cleanUp()
}
[TestMethod]
[ExpectedException(typeof(ArgumentException))]
public void testNotATime()
{
prepareNewTest();
excelex.addTimeToDict("testProject", DateTime.Today.ToString(), "Not a Time");
cleanUp();
}
两者都测试以下VB.net函数:
Public Sub addTimeToDict(projectname As String, changeDate As String, time As String)
If Not Date.TryParse(changeDate, New Date) Then
Throw New ArgumentException("changeDate is not a recoginized Date", "changeDate")
End If
If Not Date.TryParse(time, New Date) Then
Throw New ArgumentException("time is not a recoginized time format (enter HH:mm:ss", "time")
End If
///... Actuall Stuff
End Sub
任何人都知道为什么测试有效日期的第二个函数在测试资源管理器中需要15到100毫秒,而测试无效时间的第二个函数需要不到1毫秒?
还有一个空的teststub,平均需要5 ms才能执行...
它不是一个真正的错误,而是一个好奇的问题