views:

84

answers:

2

I'm writing a web application which contains a kind of schedule. After a certain action, the schedule is updated and when the user visit the page that day something happens.

Any ideas how to write a functional (acceptance) test for that kind of functionality?

I'm writing these end-to-end tests using Selenium. The only idea I have is to have a possibility to force the server to use given date by visiting an URL like /set-fixed-time?time=..., then after the test visit /set-real-time. On the server I would use a custom object to get current time and that object would be swapped when one of the URLs is visited.

+2  A: 

i think its ok for developer testing however acceptance testing should be done without mock(you could have bug in your mock code). if its has to wait 3 days than acceptance test should wait those tree days or they could by-passed it by changing server time. i think its bad idea to leave back-doors just for testing(some tester could test it by hand and than forget to /set-real-time).

01
Good points, thanks. And I might simply forget to use the time provider instead of the system time.I would make these /set-*-time services disabled in the production environment.
Adam Dziendziel
A: 

I agree with the Monkey, this is best handled by the developers.

You could also try a hybrid. There's no reason all your acceptance tests have to run on an unaltered simulation of the production site or are only allowed to use the web interface or can't alter things as an admin or can't execute code. You also don't have to change the time of the whole server, which is global and will likely have unintended consequences. You can instead change when the user was last updated.

You can drive Selenium from a program, so a hybrid Selenium and code test could use code to set a user's "when was the last time the updated" data and then execute the Selenium tests to check the outcome. Try it when its never been run, just before time runs out, exactly when time runs out and just after.

Schwern