I started with ruby about 6 weeks ago. So I am pretty new. The code I have
contains out of 4 files and works only with a specific underlying
application, which I manipulate through the code. Maybe I am misuderstanding
the use of assertions. I thought that assertions help raising errors. I
don't want to run a Unittest. So maybe my approach is wrong?
I removee < Test::Unit::TestCase
Now I get:
TEST FAILED.undefined method `assert' for #<WebAC::BPUtils:0x2c2e270>
My code: #Includes
require 'test/unit/assertions'
require 'test/unit'
# more code
$clsBPUtils = BPUtils.new
# more code
class BPUtils
require 'test/unit/assertions'
def initialize
# empty
end
def bpVerifyPopupWindowOpen( ieCont, verify)
begin
assert( ieCont.contains_text( verify) )
puts("TEST PASSED. Found test string 'Programming Ruby' ")
rescue => e
puts("TEST FAILED." + e.message + "\n" + e.backtrace.join("\n"))
end
end
···
-----Original Message-----
From: dblack@wobblini.net [mailto:dblack@wobblini.net]
Sent: Tuesday, March 21, 2006 6:05 PM
To: ruby-talk ML
Subject: Re: undefined method `add_assertion' for nil:NilClass
Hi --
On Wed, 22 Mar 2006, Paatsch, Bernd wrote:
Hello,
I tried to use assertion's the first time in my code and had
absolutely now success. I always get following error:
TEST FAILED.undefined method `add_assertion' for nil:NilClass
c:/ruby/lib/ruby/1.8/test/unit/testcase.rb:115:in `add_assertion'
c:/ruby/lib/ruby/1.8/test/unit/assertions.rb:353:in `_wrap_assertion'
c:/ruby/lib/ruby/1.8/test/unit/assertions.rb:38:in `assert'
./utils.rb:1376:in `bpVerifyOnPage'
Here is a code snipe (verify is a string that is passed to a function):
The if statement works fine. The assert gives me trouble. Why? What is
wrong? What is the nil class?
I also tried assert(true), assert_equal("1234","1234") with the same
result
The code you're posted doesn't compile, so it can't be a real example of
what's not working. Can you provide a real example?
if your parameter ieCont (I hope that does not mean what I am afraid it does
mean
is nil it cannot respond to the method contains_text and that seems to be
your problem.
It seems you did not pass an object of the expected type.
It does not really have anything to do with assert, only that the stack
trace becomes a little bit confusing sometimes.
Cheers
Robert
···
On 3/22/06, Paatsch, Bernd <BPaatsch@activevoice.com> wrote:
I started with ruby about 6 weeks ago. So I am pretty new. The code I have
contains out of 4 files and works only with a specific underlying
application, which I manipulate through the code. Maybe I am
misuderstanding
the use of assertions. I thought that assertions help raising errors. I
don't want to run a Unittest. So maybe my approach is wrong?
I removee < Test::Unit::TestCase
Now I get:
TEST FAILED.undefined method `assert' for #<WebAC::BPUtils:0x2c2e270>
My code: #Includes
require 'test/unit/assertions'
require 'test/unit'
# more code
$clsBPUtils = BPUtils.new
# more code
class BPUtils
require 'test/unit/assertions'
def initialize
# empty
end
def bpVerifyPopupWindowOpen( ieCont, verify)
begin
assert( ieCont.contains_text( verify) )
puts("TEST PASSED. Found test string 'Programming Ruby' ")
rescue => e
puts("TEST FAILED." + e.message + "\n" + e.backtrace.join("\n"))
end
end
-----Original Message-----
From: dblack@wobblini.net [mailto:dblack@wobblini.net]
Sent: Tuesday, March 21, 2006 6:05 PM
To: ruby-talk ML
Subject: Re: undefined method `add_assertion' for nil:NilClass
Hi --
On Wed, 22 Mar 2006, Paatsch, Bernd wrote:
> Hello,
>
> I tried to use assertion's the first time in my code and had
> absolutely now success. I always get following error:
>
> TEST FAILED.undefined method `add_assertion' for nil:NilClass
> c:/ruby/lib/ruby/1.8/test/unit/testcase.rb:115:in `add_assertion'
> c:/ruby/lib/ruby/1.8/test/unit/assertions.rb:353:in `_wrap_assertion'
> c:/ruby/lib/ruby/1.8/test/unit/assertions.rb:38:in `assert'
> ./utils.rb:1376:in `bpVerifyOnPage'
>
> Here is a code snipe (verify is a string that is passed to a function):
>
> The if statement works fine. The assert gives me trouble. Why? What is
> wrong? What is the nil class?
> I also tried assert(true), assert_equal("1234","1234") with the same
> result
The code you're posted doesn't compile, so it can't be a real example of
what's not working. Can you provide a real example?