sconover / wrong

Wrong provides a general assert method that takes a predicate block. Assertion failure messages are rich in detail.
MIT License
433 stars 30 forks source link

wrong assertions don't show up in count #7

Closed thegengen closed 13 years ago

thegengen commented 13 years ago

Hello. With test/unit and Ruby 1.8.7 (I can be more specific if that matters), wrong's assert { } calls don't show up in the assertion counts. Running the following file

require 'rubygems'
require 'test/unit'
require 'wrong'

class WrongTest < Test::Unit::TestCase
  include Wrong
  def test_something
    puts 'tested something'
    assert { true }
  end
end

Gives me this output:

Loaded suite wrong_test
Started
tested something
.
Finished in 0.000497 seconds.

1 tests, 0 assertions, 0 failures, 0 errors

I'm not too familiar with Test/Unit internals but with a pointer in the right direction I can probably write you a fix for this.

Oh, and thanks for this gem, I'm really loving it so far.

alexch commented 13 years ago

You need to require the testunit adapter. Try replacing

require 'wrong'

with

require 'wrong/adapters/test_unit'
thegengen commented 13 years ago

I tried that too and I get the same result. Is that working on your end?

Eugen.

alexch commented 13 years ago

Whoa! It's not. Something must be wrong (sorry) with our integration tests, since we definitely have code to handle this case.

alexch commented 13 years ago

I think we might be caught in a MiniTest trap! MiniTest defines its own Test::Unit::TestCase and sometimes it gets on the LOAD_PATH since it's included in system Ruby 1.9. More research required...

alexch commented 13 years ago
$ ruby test/adapters/test_unit_test.rb 
method(:teardown).source_location is ["/Users/chaffee/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/minitest/unit.rb", 772]

$ bundle exec ruby test/adapters/test_unit_test.rb
method(:teardown).source_location is ["/Users/chaffee/.rvm/gems/ruby-1.9.2-p180/gems/test-unit-2.1.2/lib/test/unit/testcase.rb", 401]
alexch commented 13 years ago

Fixed (i hope) with new release 0.5.2. Please 'gem update' and check it out.

thegengen commented 13 years ago

It is working indeed but the behavior isn't ideal if the test-unit gem is missing from my system altogether. (I get a LoadError instead of the message from wrong_adapter_failure.)

I submitted a pull request for a test that fails on my machine. Once that's sorted out, I'll write a test and a patch for the behavior I'm seeing. That is, unless you want to open another ticket now and do it yourself.

alexch commented 13 years ago

Hm. I suppose I need to rescue LoadError explicitly since it's an Error not an Exception, or something like that.

On Fri, Jul 8, 2011 at 4:31 AM, minciue reply@reply.github.com wrote:

It is working indeed but the behavior isn't ideal if the test-unit gem is missing from my system altogether. (I get a LoadError instead of the message from wrong_adapter_failure.)

I submitted a pull request for a test that fails on my machine. Once that's sorted out, I'll write a test and a patch for the behavior I'm seeing. That is, unless you want to open another ticket now and do it yourself.

Reply to this email directly or view it on GitHub: https://github.com/sconover/wrong/issues/7#issuecomment-1531844

Alex Chaffee - alex@cohuman.com - http://alexch.github.com Stalk me: http://friendfeed.com/alexch | http://twitter.com/alexch | http://alexch.tumblr.com