How do I run all the unit tests I have in a single command folder?

I have, 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 in another test file?

I am using test / unit gem.

+3


source to share


1 answer


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

For example, I can create a file all.rb

inside my folder test

using this code:

Dir[File.dirname(File.absolute_path(__FILE__)) + '/**/*_test.rb'].each {|file| require file }

      



This will run every *_test.rb

file found inside the folder tree test

.

Run it ruby -Itest test/all.rb

from the project root.

+4


source







All Articles