黄瓜清理
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在您的
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 adb: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.这是我在 Sam Livingston-Gray 的评论中提到的调试步骤的定义:
Here's the definitino for the debug step I mentioned in the comment to Sam Livingston-Gray:
有点黑客,但作为最后的手段,也许您可以添加一个名为“然后暂停测试”的 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.)