How do I format a timer in TestPartner so that I can read the elapsed time?
TestPartner has three timer systems available to it:-
1. The TestPartner internal system (the TClock object)
2. The operating system's clock by calling the VBA 'Now' method
3. The high precision VBA Timer object.
The first two present the elapsed time in a format that is not immediately readable or useable.The high precision timer would be most suitable for timing the execution of a script or part of a script.
The following short TestPartner script takes each of these timer systems and outputs a formatted result to a messagebox. Methods (1) and (3) present the result only in seconds and fractions of a second, so if your timer is going to exceed one minute you may wish to add further code to produce an hh:mm:ss formatted output.
' TestPartner Native in seconds and fractions
Dim tc As TClock
Set tc = Clock("myClock")
MsgBox "Time format test - Testpartner Native - 3 secs"
Pause 3, tpPauseSeconds
MsgBox (CStr(tc.Elapsed / 1000))
' Operating system time in whole seconds
MsgBox "Time format test - O/S - 2 secs"
Start = Now
Pause 2, tpPauseSeconds
Finish = Now
MsgBox (Format(Finish - Start, "hh:mm:ss"))
' High precision in seconds and fractions
MsgBox "Time format test - VBA timer - 4 secs"
Start = Timer
Pause 4, tpPauseSeconds
Finish = Timer
MsgBox (Finish - Start)