ruby - How do I run a Test::Unit suite to completion with a tally of tests/failures? -
i've inherited large suite of test::unit tests, , 1 of first tasks have suite run completion rather exit after first test failure.
i'm rescuing assertionfailederror
, ensuring output string, seems wrong. what's better way? seems configuration option.
some more background helpful. can't understand behavior you're seeing.
i'm using both core test/unit lib comes ruby 1.8, several versions of gem ruby 1.9. normal behavior both of these run entire loaded suite completion , summarize results.
running script says require 'test/unit'
add on-exit hook run test::unit::autorunner
test::unit::collector::objectspace
collector (i.e. runs every instance of test::unit::testcase
loaded in global object space).
it's easy write own custom test runner manually loads test classes , packs them test::unit::testsuite
, , capture results.
but every version of test/unit i've used, i've seen entire suite finish , report both failures , errors. in lieu of further info, i'd suggest experimenting single dummy test see how should expect test/unit behave.
for example
require 'test/unit' class foo < test::unit::testcase def testfoo flunk 'bad foo' end end class bar < test::unit::testcase def testbar raise 'bar bar' end end
gives
loaded suite foo started ef finished in 0.001000 seconds. 1) error: testbar(bar) runtimeerror: bad bar foo.rb:9:in `testbar` 2) failure: testfoo(foo) [foo.rb:4]: bad foo 2 tests, 1 assertions, 1 failures, 1 errors, 0 skips
lastly: trying rescue/ensure? in test methods? under normal circumstances, there's no reason catch assertionfailederror. test::unit::testcase
do, way count failures , give report want. catching interferes test/unit written do.
Comments
Post a Comment