Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Run Single Test

DZone's Guide to

Run Single Test

·
Free Resource
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

Topics:

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}