I'm having a test hang in our rails app can't figure out which one (since it hangs and doesn't get to the failure report). I found this blog post http://bmorearty.wordpress.com/2008/06/18/find-tests-more-easily-in-your-testlog/ which adds a setup hook to print the test name but when I try to do the same thing it gives me an error saying wrong number of arguments for setup (1 for 0). Any help at all would be appreciated.
If you run test using rake it will work:
rake test:units TESTOPTS="-v"
The printing of the test name is the responsibility of the TestRunner. If you are running your tests from the command line you can specify the -v option, to print out the test case names.
example:
ruby test_Foo.rb -v
Loaded suite test_Foo
Started
test_blah(TestFoo): .
test_blee(TestFoo): .
Finished in 0.007 seconds.
2 tests, 15 assertions, 0 failures, 0 errors
This is what I use, in test_helper.rb
class Test::Unit::TestCase
# ...
def setup_with_naming
unless @@named[self.class.name]
puts "\n#{self.class.name} "
@@named[self.class.name] = true
end
setup_without_naming
end
alias_method_chain :setup, :naming unless defined? @@aliased
@@aliased = true
end
The @@aliased variable keeps it from being re-aliased when you run it on multiple files at once; @@named keeps the name from being displayed before every test (just before the first to run).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With