[英]Ruby: How to run all unit tests that I have in a folder with a single command?
I have, let's say: 我有,说:
emp_test.rb
sales_emp_test.rb
corporate_emp_test.rb
payroll_emp_test.rb
How can I run them all together? 我如何一起运行它们? Should I include them into another test file?
我应该将它们包含在另一个测试文件中吗?
I am using test/unit gem. 我正在使用测试/单位宝石。
Create another ruby file and require all test files you want to run. 创建另一个ruby文件,并要求您要运行的所有测试文件。
For example, I can create an all.rb
file inside my test
folder with this code: 例如,我可以使用以下代码在
test
文件夹中创建all.rb
文件:
Dir[File.dirname(File.absolute_path(__FILE__)) + '/**/*_test.rb'].each {|file| require file }
That would run every *_test.rb
file found inside the test
folder tree. 这将运行在
test
文件夹树中找到的每个*_test.rb
文件。
Run it with ruby -Itest test/all.rb
from your project root. 从项目根目录使用
ruby -Itest test/all.rb
运行它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.