使用 minitest 进行多次测试
我有一个应用程序,其中一些规格写入 minitest 中。像往常一样,我使用 rake
启动它们。
因为有时我得到的是随机结果,所以我的规格可能一次通过,另一次失败。
在这种情况下,我可以保留序列号并在修复后稍后重播。 因为我有这种测试(随机结果),所以我通常运行 rake 多次,只是为了确保应用程序没问题。
我想知道是否有一种很好的方法来执行多次 rake
测试(例如 100 次),并在出现任何失败或错误时停止它们?
I have an app with some specs written into minitest. As usual, I start them using rake
.
Because some times I got a random results, my specs can pass one time, and fail an other time.
In this case, I can keep the sequence number and replay it later, after fixing.
Because I have this kind of tests (with a random result), I generally run rake
many time, just to be sure that the app is okay.
I would like to know if there is a nice way to perform multiple rake
tests (100 times for example), and stop them if there any failure or any error?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为你应该重新考虑你的测试,而不是测试通话。随机结果的测试对我来说看起来是错误的。
你的测试中的随机因素是什么?您可以为随机因子编写一个模拟元素,并使用模拟元素的不同值重复测试吗?这样你就得到了一个“完整”的测试。
I think you should think again about your test, not about the test call. A test with a random result looks wrong for me.
What's the random factor in your test? Can you write a mock-element for the random factor and repeat the test with different values for the mock-element. So you get a "complete" test.
我创建了一个具有随机结果的虚拟测试来模拟您的情况:
以下任务调用测试 10 次,并在第一次失败后停止:
对于实际使用,我将调整一些部分:
puts 'Tests ok'
定义一个计数器来查看测试成功的频率。I created a dummy test with random result to simulate your situation:
The following task calls the test 10 times and stops after the first failure:
For real usage I would adapt some parts:
puts 'Tests ok'
define a counter to see how often the test was succussfullputs stdout
you may store the result in a result file?