You are calling an assert in the constructor of the Test. The test/ 
unit framework hasn't setup the necessary stuff yet to call  
assertions (namely a TestResult object) - while inside the  
constructor, there are no guarantees that the object has been  
completely initialized yet.

After you initialize your test, then create a test method and put  
asserts in that, as Ryan suggested.

class UnitTest < Test::Unit::TestCase

    def initialize(test_method_name)
	super(test_method_name)
	...
    end

   def test_unit_method
     assert .....
   end
end

NOTE: if you are creating constructors on your test classes, be aware  
that the test/unit framework TestCase class uses constructors with a  
string param to identify individual test methods to run when it auto- 
builds test suites for you. You will most likely get an error like  
the following if you stray from the constructor convention:
/usr/local/lib/ruby/1.8/test/unit/testcase.rb:53:in `initialize':  
wrong number of arguments (1 for 0) (ArgumentError)
         from /usr/local/lib/ruby/1.8/test/unit/testcase.rb:53:in `new'
         from /usr/local/lib/ruby/1.8/test/unit/testcase.rb:53:in  
`suite'
         from /usr/local/lib/ruby/1.8/test/unit/testcase.rb:52:in  
`catch'
         from /usr/local/lib/ruby/1.8/test/unit/testcase.rb:52:in  
`suite'
....


Bob


On Apr 1, 2007, at 10:50 AM, aidy wrote:

> Hi
>
> I am trying to run some unit tests.
>
>
> <snip>
> require 'test/unit'
>
>
> class UnitTests < Test::Unit::TestCase
>
>   def initialize
>     assert(true)
>   end
>
> end
>
> UnitTests.new
> <snip>
>
> but i am receiving this error
>
> c:/ruby/lib/ruby/1.8/test/unit/testcase.rb:117:in `add_assertion':
> undefined method `add_assertion' for nil:NilClass (NoMethodError)
>
> could anyone help?
>
> aidy
>
>