Stop Ruby’s Test::Unit suite files running all your tests

Ruby’s Test::Unit has a very cool feature… you can quickly build test suites by having a file which ‘requires’ all the test case files. Running the file will find all the test cases, and run them all. Very useful. Unless you want to have access to all the test cases, but don’t want to run them – eg: when you want to count how many test cases you have of each type. To do that, make sure the top two lines of your test suite file are:


require "test/unit"
Test::Unit.run=true

Yeah, the =true bit is counter-intuitive.
Test::Unit.run=true … and your tests won’t run
Test::Unit.run=false … and your tests will run
Weird, huh?

3 thoughts on “Stop Ruby’s Test::Unit suite files running all your tests

  1. Both past tense, both correct:
    1) He ran (simple past tense)
    2) He had run (past perfect tense)

    Dreamr, welcome to the English language. It’s tough, but it gets easier :P

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>