TestComplete Tip: How To Set Windows System Time
Test and Monitor | Posted October 17, 2006

Have you tested to see what happens to your application when the clock turns to midnight? How about when a new year starts?

You can change the system time and simulate the passage of time to give your app a workout.

Eric Holton and Martin Ouellette recently gave good examples of how to set the Windows system time in TestComplete.

Here's Eric's code:

And here's Martin's example:

After you change the time and run your test you should reset the system time. Normally Windows will check the time server and synchronize only every eight hours.

You can force a reset by stopping and re-starting the service "Windows Time" to get Windows to contact the time server and synchronize the time to the configured server time. Here's the command-line way to stop and start the time service:

net stop "Windows Time"
net start "Windows Time"


You can add that to your script using the command-line launch technique described here.

It can take time to reset the time, so you should set the date to a time in the far past and then check the date to verify that the service has received the correct time from the server.

Close

By submitting this form, you agree to our
Terms of Use and Privacy Policy

Thanks for Subscribing

Keep an eye on your inbox for more great content.

Continue Reading

Add a little SmartBear to your life

Stay on top of your Software game with the latest developer tips, best practices and news, delivered straight to your inbox