问题
I am using Ruby 1.9.2 (ruby -v yields :ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-linux]), and I am trying to get this to work:
require 'test/unit'
class TestStartup < Test::Unit::TestCase
def self.startup
puts "startup"
end
def test1
puts "in test1"
end
end
when I run it, I get
Loaded suite test_startup
Started
in test1
.
Finished in 0.000395 seconds.
1 tests, 0 assertions, 0 failures, 0 errors, 0 skips
I had a hard time finding documentation on this feature, other than scattered posts here on SO and the like.
And yes, I want to use this feature and not setup.
TIA
回答1:
Ruby 1.9.x bundles minitest not Test::Unit. Test::Unit bundled in Ruby 1.8.x had not been improved but unbundled Test::Unit (test-unit 2) will be improved actively.
So you must be using the Test::Unit gem? Is it perhaps an older version which doesn't support this feature?
回答2:
Ruby 1.9.2 uses Minitest instead of Test::Unit by default, so it might be that this feature is missing from Minitest.
来源:https://stackoverflow.com/questions/7639582/cant-get-test-unit-startup-to-work-in-ruby-1-9-2