Jack
Jack

Reputation: 763

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.

Upvotes: 7

Views: 4331

Answers (1)

RubenCaro
RubenCaro

Reputation: 1466

Create another ruby file and require all test files you want to run.

For example, I can create an all.rb file inside my test folder with this code:

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.

Run it with ruby -Itest test/all.rb from your project root.

Upvotes: 11

Related Questions