TestGarden
¶ ↑
A garden of forking tests.
TestGarden
is a testing framework for concisely sharing several stages of setup code across tests. The shared code is executed once for each test that needs it. Tests may be nested to any depth.
TestGarden
generates summary output, reporting how many pass, fail, skip, and error cases were detected for each group of tests. TestGarden
assumes assertion failure exceptions are generated by Wrong::Assert#assert.
Synopsis:
require 'test-garden' test Thing do thing = Thing.new; teardown {thing.cleanup()} assert {thing.ok?} test "assign foo" do thing.foo = "baz" # does not affect foo in subsequent tests assert {thing.foo == "baz"} end test "compare foo in two instances" do thing2 = Thing.new; teardown {thing2.cleanup()} assert {thing.foo == thing2.foo} end end
Run the test like so:
ruby test_thing.rb [-v | --verbose] [topic topic ...]
If no topics are given, the verbose output is:
T: Thing T: Thing: assign foo P: Thing: assign foo T: Thing T: Thing: compare foo in two instances P: Thing: compare foo in two instances 2 passed, 0 failed, 0 skipped, 0 errors in Thing
If a topic list is given, it is treated as a sequence of regular expressions. Only tests whose topic path matches those regular expressions, one for one, are executed. (Matching is case insensitive.) For example:
ruby testfilename.rb thing compare
This executes only the the last test. The verbose output is:
T: Thing S: Thing: assign foo T: Thing T: Thing: compare foo in two instances P: Thing: compare foo in two instances 1 passed, 0 failed, 1 skipped, 0 errors in Thing
Note that the “assign foo” test was skipped, and counted as such.
[1] In reference to “The garden of forking paths”, by J.L. Borges.