A feature of ours requires the SUT's execution over various days. We would like to cover this functionality within our integration tests.

So I was wondering, is it possible and safe to advance/modify the system time during the execution of a test suite? What are the (side) effects? I assume that the dates and execution spans in the report will get mixed up inevitably.

Regarding code to change the system time in C#, I have found this Stack Overflow post: Change system date programmatically.

Do other test strategies/approaches/patterns come to your mind, that avoid fiddleing around with the system time?


It depends on how much impact changing the system dates/time has on your work.

  • As you mentioned in your question, I assume that the dates and execution spans in the report will get mixed up inevitably. Personally, I do not see it as a major impact as you can easily generate your report after you undo the changes you have made to your system dates/time.

Several major impacts I can think of are:

  • Is your SUT automatically synced to an external clock? What kinds of consequences are there if you changes system dates/time when SUT constantly complaints about it.
  • Your security certificates, anti-malware, anti-virus, VPN link and even website admin sessions will fail.

The safest strategy I can think of is:

  • Sandbox your SUT in a virtual environment first, make changes to your system dates/time, run your tests, observe what consequences there are.

If you are not really under a tight schedule, run your integration tests without fiddling with system dates/time; it is more realistic that way.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.