add_assertion' called for nil:NilClass errror when testing

Discussion in 'Ruby' started by Arti Singh, Oct 27, 2009.

  1. Arti Singh

    Arti Singh Guest

    This @browser is defined in the login method
    @browser=Selenium::Client::Driver.new("localhost", 4444, "*chrome", $url
    , 10000);

    class CrudDContent<Test::Unit::TestCase
    def initialize()
    login("browser_name")
    end#initialize()

    def test_createdc()
    assert(@browser.element?($x_xpath))#the test fails at this assert
    end#test_createdc()




    end#CrudDContent<Test::Unit::TestCase



    When ever I run this program, I get the error :

    C:/RubyInstall/ruby/lib/ruby/1.8/test/unit/testcase.rb:125:in
    `add_assertion': private method `add_assertion' called for nil:NilClass
    (NoMethodError)
    from C:/RubyInstall/ruby/lib/ruby/1.8/test/unit/assertions.rb:494:in
    `_wrap_assertion'
    from C:/RubyInstall/ruby/lib/ruby/1.8/test/unit/assertions.rb:61:in
    `assert'
    from ./content.rb:6:in `test_createdc'
    from Driver.rb:8

    Can someone take a look, I am out of ideas!
    --
    Posted via http://www.ruby-forum.com/.
     
    Arti Singh, Oct 27, 2009
    #1
    1. Advertising

  2. Arti Singh

    Arti Singh Guest

    Fixed, I needed to add the initalize the test methods after I called
    them




    dc=CrudDContent.new()

    def initialize(dc)
    super(dc)
    end #def initialize(dc)

    dc.test_createdc()




    Arti Singh wrote:
    > This @browser is defined in the login method
    > @browser=Selenium::Client::Driver.new("localhost", 4444, "*chrome", $url
    > , 10000);
    >
    > class CrudDContent<Test::Unit::TestCase
    > def initialize()
    > login("browser_name")
    > end#initialize()
    >
    > def test_createdc()
    > assert(@browser.element?($x_xpath))#the test fails at this assert
    > end#test_createdc()
    >
    >
    >
    >
    > end#CrudDContent<Test::Unit::TestCase
    >
    >
    >
    > When ever I run this program, I get the error :
    >
    > C:/RubyInstall/ruby/lib/ruby/1.8/test/unit/testcase.rb:125:in
    > `add_assertion': private method `add_assertion' called for nil:NilClass
    > (NoMethodError)
    > from C:/RubyInstall/ruby/lib/ruby/1.8/test/unit/assertions.rb:494:in
    > `_wrap_assertion'
    > from C:/RubyInstall/ruby/lib/ruby/1.8/test/unit/assertions.rb:61:in
    > `assert'
    > from ./content.rb:6:in `test_createdc'
    > from Driver.rb:8
    >
    > Can someone take a look, I am out of ideas!


    --
    Posted via http://www.ruby-forum.com/.
     
    Arti Singh, Oct 27, 2009
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Petrucci Fabio
    Replies:
    1
    Views:
    124
    Jim Weirich
    Jul 13, 2004
  2. Petrucci Fabio
    Replies:
    1
    Views:
    129
    Jim Weirich
    Jul 13, 2004
  3. Paatsch, Bernd
    Replies:
    1
    Views:
    155
  4. Christoffer Sawicki
    Replies:
    5
    Views:
    288
    Christoffer Sawicki
    Sep 2, 2006
  5. Mr. Bill
    Replies:
    2
    Views:
    571
    Mr. Bill
    Dec 30, 2010
Loading...

Share This Page