批量运行时RSpec错误,但不是单独运行 [英] RSpec errors when run en masse, but not individually

查看:84
本文介绍了批量运行时RSpec错误,但不是单独运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

不幸的是,我没有一个具体的问题(或线索),但希望有人能指出我正确的方向。

Unfortunately I don't have a specific question (or clues), but was hoping someone could point me in the right direction.

当我全部跑完时测试(rspec规范),我得到了两个失败的测试,这些测试特别与延迟作业有关。

When I run all of my tests (rspec spec), I am getting two tests that fail specifically related to Delayed Job.

当我单独运行此规范文件时(rspec ./spec/controllers/ xxx_controller_spec.rb)所有测试都通过了……这是常见问题吗?我应该找什么?

When I run this spec file in isolation (rspec ./spec/controllers/xxx_controller_spec.rb) all the tests pass...... Is this a common problem? What should I be looking for?

谢谢!

推荐答案

您已经提到过:隔离可能是解决方案。通常,我会猜测您数据库中的某些东西正在更改并且没有正确清理(或者没有正确模拟)。

You are already mentioning it: isolation might be the solution. Usually I would guess that you have things in the database that are being changed and not cleaned up properly (or rather, are not not mocked properly).

在这种情况下,尽管我建议这样做,但是由于系统的工作量很高,所以延迟的工作还不够快。挑战在于应测试的所有异步任务:您不得让系统运行延迟的作业,而应模拟调用并确保已收到延迟的作业。

In this case though I would suggest that, because the system is quite under a high workload, the delayed jobs are not being worked off fast enough. The challenge is with all asynchronous tasks that should be tested: you must not let the system run the delayed jobs, but mock the calls and just make sure that the delayed jobs have been received.

遗憾的是,没有示例,我很难指出缺少的模拟对象。但是请确保所有对delay_jobs的调用和类似调用都接收到正确的数据,但实际上并未创建和运行这些作业-您的规范也将更快。确保隔离测试中的函数,并且不调用外部依赖项。

Sadly, with no examples, I can hardly point out the missing mocks. But make sure that all calls to delay_jobs and similar receive the correct data, but do not actually create and run those jobs - your specs will be faster, too. Make sure you isolate the function under test and not call external dependencies.

这篇关于批量运行时RSpec错误,但不是单独运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆