[Development] date/time adjust for (auto) testing

Henry Skoglund fromqt at tungware.se
Wed Jun 3 09:09:16 CEST 2015


Hi, I also had the same needs for testing my app, on different times of 
the day or year etc. But instead of patching Windows or some Qt code, I 
created a new virtual Windows VM in WMWare, and deployed my app into it.

Switched off "Synchronize guest time with host" in the Options, and 
whenever I test, first a .bat file is run that sets the requested 
date/time in the Windows VM. This can you do in VirtualBox as well.

Note that when you run on a fake date/time, https (certificates) and a 
lot of other internet stuff will fail, but for local app testing it's ok.

Rgrds Henry


On 2015-06-03 08:38, André Somers wrote:
> Hi,
>
> We have applications that use the current date and time at places spread
> around the code. For normal operations, that works very nicely. However,
> we find that for (auto) testing, it would be very convenient if we could
> trick the application into believing it is some other date/time, so that
> we can test if certain behaviours work the way we would like to
> automatically. Currently, these tests take a lot of time because we
> actually need to manually adjust the system date and time, do some
> stuff, then adjust again, etc.
>
> It would be really confortable if there was some control to set a
> date/time offset (so the time keeps running) or a fixed date/time to be
> returned from currentDate(), currentTime() or currentDateTime()
> respectively. I guess access to such a thing does not belong in the main
> Qt classes, but is really a testing tool, so perhaps it could find
> refuge in QtTest somewhere. Would a contribution adding such a thing
> stand any chance of being accepted, or would this be considered out of
> scope or even unwanted?
>
> An alternative might be to hook the windows kernel API, but that may be
> much tricker to get right and may have unforseen consequences for the
> code injected by Squish doing the actual testing.
>
> André
>





More information about the Development mailing list