Test::Unit mixup

Suddenly test::unit is failing for me. The following 2-line script comes up with

"testu.rb:2: undefined method `assert' for main:Object (NoMethodError)"

testu.rb contains:

1: require 'test/unit'
2: assert(1==1)

What have I broken or forgot?
ruby 1.8.2 (2004-12-25) [i386-mswin32]

It fails the same way under irb.

Warren

Warren Seltzer schrieb:

Suddenly test::unit is failing for me. The following 2-line script comes up with
"testu.rb:2: undefined method `assert' for main:Object (NoMethodError)"
testu.rb contains:
  1: require 'test/unit'
2: assert(1==1)

What have I broken or forgot?
ruby 1.8.2 (2004-12-25) [i386-mswin32]

Hi Warren,

normally the assert methods are accessible in subclasses of Test::Unit::TestCase. You could change your code to

   require 'test/unit'
   class AssertionTest < Test::Unit::TestCase
     def test_assert
       assert(1==1)
     end
   end

If you want to use assertions outside of testcases, look at module Test::Unit::Assertions.

Regards,
Pit