如何使用 Cucumber 测试 DelayedJob?

发布于 2024-09-26 18:19:30 字数 166 浏览 0 评论 0原文

我们使用 DelayedJob 来运行一些长时间运行的进程,并希望使用 Cucumber/Webrat 进行测试。

目前,我们在 Ruby 线程中调用 Delayed::Job.work_off 来在后台完成工作,但正在寻找更强大的解决方案,

最好的方法是什么?

谢谢。

We use DelayedJob to run some of our long running processes and would like to test with Cucumber/Webrat.

Currently, we are calling Delayed::Job.work_off in a Ruby thread to get work done in the background, but are looking for a more robust solution

What is the best approach for this?

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

我不咬妳我踢妳 2024-10-03 18:19:30

我发现 Delayed:Job.work_off 方法的主要问题是,您在 Cucumber 场景中明确了属于系统内部的内容。混合这两个问题违背了功能测试的精神:

When I click some link # Some operation is launched in the background
And Jobs are dispatched # Delayed:Job.work_off invoked here
Then I should see the results...

另一个问题是,您在 Cucumber 场景中填充了重复步骤,以便在需要时分派作业。

我目前使用的方法是在黄瓜场景下在后台启动delayed_job正在执行。您可以检查我在该链接中使用的黄瓜钩子。

The main problem I see with the Delayed:Job.work_off approach is that you are making explicit in your Cucumber scenarios something that belongs to the internals of your system. Mixing both concerns is against the spirit of functional testing:

When I click some link # Some operation is launched in the background
And Jobs are dispatched # Delayed:Job.work_off invoked here
Then I should see the results...

Another problem is that you populate your Cucumber scenarios with repetitive steps for dispatching jobs when needed.

The approach I am currently using is launching delayed_job in the background while cucumber scenarios are being executed. You can check the Cucumber hooks I am using in that link.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文