为什么rspec运行不同数量的测试?

时间:2017-12-26 23:50:49

标签: ruby-on-rails rspec

我意识到这是一个非常广泛的问题但是我已经看到我们的测试运行800或1,500个单独测试并且两次都通过。是什么导致rspec在不同版本上运行不同数量的测试?

1 个答案:

答案 0 :(得分:0)

我相信它是以随机顺序进行Rspec运行测试。浏览此处获取更多信息。

Rspec order option

例如,如果您想要查看相同的测试结果并仍想随机运行它们,您可以执行以下操作

  

当您使用--order random时,RSpec打印出随机数   用于播种随机数发生器。

     

- 命令rand:1234 - order default告诉RSpec在每个文件中声明它们时加载组和示例

bundle exec rspec --order rand ## for example this will results with a seed 1234

如果你想以相同的随机顺序运行相同数量的测试,你可以运行

bundle exec spec --order rand:1234 # This will always run the test in same random order with the given seed (1234)