DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Run Single Test

07.13.2009
| 10847 views |
  • submit to reddit
        tests should be run with rake to load the test environment

run all tests  
$ rake test

run only one unit test
$ rake test:units TEST=test/unit/xy_test.rb

run tests done wrong and right
==============================

run one test. WRONG. 
Doesn't load test environment. "require test_helper" fails!
$ ruby test/unit/glosentry_test.rb

run only one test. WRONG. runs test three times
$ rake test TEST=test/unit/glosentry_test.rb

run only the unit tests with rake. RIGHT 
$ rake test:units

run only one unit test with rake. RIGHT. (same as obove)
$ rake test:units TEST=test/unit/xy_test.rb

running one test without rake but with explicit $-loadpath works too
here "ruby -I directory" specifies the $loadpath.
$ ruby -I test test/unit/xy_test.rb