使用 capybara 和 selenium 获取要显示的 Rails 异常
在使用 capybara 和 selenium 在 Rails 中运行集成测试时,如果引发异常,则会显示空白页面,而不是带有堆栈跟踪的常见异常屏幕。有没有办法让水豚显示堆栈跟踪页面?
In using capybara and selenium to run integration tests in rails, if an exception is raised a blank white page is shown instead of the usual exception screen with the stack trace. Is there a way to get capybara to show the stack trace pages?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我无法使用 Webrick 或 Thin 来显示堆栈跟踪,但我最终的解决方法是使用 Mongrel,它可以正确地将堆栈跟踪打印到 stderr。
使用 capybara 0.4.1.2 或更高版本,您可以将 capybara 配置为使用 mongrel,如下所示:
I was not able to get the stack traces to show with Webrick or Thin, but my eventual workaround was to use Mongrel, which properly prints the stack traces to stderr.
With capybara 0.4.1.2 or later, you can configure capybara to use mongrel like so:
马特的解决方案对我不起作用,但正是这个要点 https://gist.github.com/1443408
做过。
https://github.com/thoughtbot/capybara-webkit/issues/226 更详细地解释了原因它
发生并解释给定要点的作用。
Matt's solution didn't work for me, but precisely this gist https://gist.github.com/1443408
did.
https://github.com/thoughtbot/capybara-webkit/issues/226 explains in more detail why it
happens and provides explanation on what given gist does.
这很可能是因为堆栈跟踪仅在开发执行模式(或“环境”)中显示,并且您的集成测试在开发中运行>生产环境。
当然,通过调整生产模式设置,您也许可以使其显示异常。但这不是正确的方法。最好的方法是:
文件或日志服务器中(hoptoad?)
用户看不到它但你
可以
错误页面
希望这有帮助。此致。
this is most likely because the stack trace is only shown in the development execution mode (or 'environment'), and your integration tests are run within the production environment.
Of course, by tweaking the production mode settings, you may be able to make it show the exception. But it would not be the correct way. The best way is to :
a file or in a log server (hoptoad ?)
where the user cannot see it but you
can
error page
Hope this helps. Best regards.