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. For example, I can create an all.rb file inside my test folder with this code: That would run every *_test.rb file found inside the test folder tree.
With dynamically typed languages such as Ruby there is no compiler around to check the code, so it is even more important that unit tests are in place to help verify the code’s correctness. Testing in Ruby? Ruby offers a couple of test frameworks, among these are Test::Unit which is available in Ruby 1.8 and MiniTest::Unit available in Ruby 1.9.
The unit directory will contain our unit tests, these will be the tests for the model classes in the Rails application. Functional tests will typically test our controllers and integration testing involves end-to-end testing. When you create a model in Rails a unit test is created automatically.
Rails Testing. There is also a ‘fixtures’ sub directory that we’ll come back to. The unit directory will contain our unit tests, these will be the tests for the model classes in the Rails application. Functional tests will typically test our controllers and integration testing involves end-to-end testing.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With