如何从功能上测试在给定时间应该发生什么事情?
我正在编写一个包含某种时间表的网络应用程序。 执行特定操作后,计划会更新,当用户当天访问该页面时,会发生一些事情。
有什么想法如何为这种功能编写功能(验收)测试吗?
我正在使用 Selenium 编写这些端到端测试。 我唯一的想法是可以通过访问 /set-fixed-time?time=...
这样的 URL 来强制服务器使用给定的日期,然后在测试后访问 /设置实时
。
在服务器上,我将使用自定义对象来获取当前时间,并且当访问其中一个 URL 时该对象将被交换。
I'm writing a web application which contains a kind of schedule. After a certain action, the schedule is updated and when the user visits 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 the possibility to force the server to use a given date by visiting a 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 the current time and that object would be swapped when one of the URLs is visited.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为开发人员测试可以,但是验收测试应该在没有模拟的情况下完成(您的模拟代码中可能有错误)。 如果必须等待 3 天,那么验收测试应该等待这三天,否则他们可以通过更改服务器时间来绕过它。 我认为仅仅为了测试而留下后门是个坏主意(一些测试人员可以手动测试它而不是忘记/设置实时)。
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).
我同意猴子的观点,这最好由开发人员来处理。
您也可以尝试混合动力。 没有理由所有验收测试都必须在未更改的生产站点模拟上运行,或者只允许使用 Web 界面,或者不能以管理员身份更改内容或无法执行代码。 您也不必更改整个服务器的时间,这是全局的,并且可能会产生意想不到的后果。 您可以更改用户上次更新的时间。
您可以从程序驱动 Selenium,因此混合 Selenium 和代码测试可以使用代码来设置用户的“上次更新时间”数据,然后执行 Selenium 测试来检查结果。 在从未运行过的情况下、在时间用完之前、恰好在时间用完时以及在时间用完之后尝试。
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.