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

问题描述 投票:0回答:1

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

ruby-on-rails rspec
1个回答
0
投票

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

Rspec order option

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

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

--order 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)
© www.soinside.com 2019 - 2024. All rights reserved.