黄瓜清理

发布于 2024-08-13 07:08:06 字数 132 浏览 7 评论 0原文

SO Folk,

这些部分周围的任何人都知道是否可以阻止 Cucumber 在运行结束时清理测试数据?我有一些测试仍然失败,我想看看支持这些测试的数据......

有什么想法吗?

谢谢! 科里·威尔克森

SO Folk,

Anyone around these parts know if you can keep Cucumber from cleansing test data at the end of a run? I've a few tests that continue to fail and I'd like to have a look at the data backing those tests...

Any ideas?

Thanks!
Cory Wilkerson

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

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

发布评论

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

评论(3

落日海湾 2024-08-20 07:08:06

在您的 features/support/env.rb 文件中,有一些关于此的注释。如果您不想在特定场景完成后回滚数据库,请将 @no-txn 标记添加到场景中。然后您需要自己清理数据库。最简单的方法是执行db:test:clone

解决问题的最佳方法是单独运行问题场景并查看每个场景是如何失败的。如果您进行运行并遇到将数据留在数据库中的情况,那么您会给自己带来各种问题。一旦修复了该场景,就可以在处理下一个场景或运行之前执行db:test:clone

In your features/support/env.rb file there are some comments about this. If you don't want to roll-back the database after a particular scenario has finished then add the @no-txn tag to the scenario. You will then need to clean the db yourself. The easiest way is to do a db:test:clone.

The best way to troubleshoot your issues would be to run the problem scenarios individually and see how each one is failing. If you do a run and have scenarios leaving data in the DB then you are going to cause yourself all kinds of problems. Once you have fixed the scenario then do a db:test:clone before you work on the next one or do a run.

﹉夏雨初晴づ 2024-08-20 07:08:06

这是我在 Sam Livingston-Gray 的评论中提到的调试步骤的定义:

When /I want to debug/i do
  debugger
  true # never put debugger at the end of a method
end

Here's the definitino for the debug step I mentioned in the comment to Sam Livingston-Gray:

When /I want to debug/i do
  debugger
  true # never put debugger at the end of a method
end
俏︾媚 2024-08-20 07:08:06

有点黑客,但作为最后的手段,也许您可​​以添加一个名为“然后暂停测试”的 Then 块,该块要么停止,要么进入轮询循环并且不会继续,直到它看到某些条件变化(例如,您触摸/功能/继续.txt)?

在您想要查看的测试中坚持“然后暂停测试”,您就可以在继续之前检查数据库。当然,如果 Cucumber 使用数据库事务,这将不起作用...

(很抱歉含糊其辞;自从我上次使用 Cucumber 以来已经有一段时间了。)

A bit hackish, but as a last resort, maybe you could add a Then block called "Then pause tests" that either halts, or goes into a polling loop and doesn't continue until it sees some condition change (e.g., you touch /features/continue.txt)?

Stick "Then pause tests" in the test you want to look at, and you've got a way to inspect the database before it continues. Of course, this doesn't work if Cucumber uses database transactions...

(Sorry for the vagueness; it's been a while since I last used Cucumber.)

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