Re: [Wtr-general] report failure question?

2006-09-23 Thread Bill Agee
Here are some other suggestions:

1) Perhaps try adding messages to your asserts.  If you just want some
extra logging when failures occur, this may be all you need to do.
All the assert methods I've seen support this; just add the message as
the last arg you pass to the assert call.

The message will show up in the test results if the test fails (even
when using Test::Unit::Reporter; the message will be in the type
column for failed test methods).  And as you might expect, you can use
#{} to interpolate variables in the message (from what I've seen, at
least. :) ).  This is really useful if you want to have extra
descriptive text beyond nil is not true after failed asserts.  For
example:

assert($ie.link(:text, nameOfLink).exists?, Link with text
'#{name_of_link}' was not found!)

2) Another cool technique that Bret suggested to the list a month or so ago:

See http://www.mail-archive.com/wtr-general@rubyforge.org/msg04849.html

- Add this method to your test class:


  def verify boolean, message = 'verify failed.'
add_assertion
add_failure message, caller unless boolean
  end


- Now call the verify method instead of assert, and your test will
continue executing even if the verification fails:


test_testMethodFoo
  result = verify($ie.link(:text, nameOfLink).exists?)
  puts Test is still executing...
  if !result
do_some_extra_stuff()
  end
end


I may not be using that method in the intended fasion, but this
technique brings up a lot of possibilities, regardless.

Thanks
Bill


On 9/22/06, Luke [EMAIL PROTECTED] wrote:
 I answer myself I've done something like this:

 begin
 assert($ie.link(:text, 'name_of_link').exists?)
 rescue =e
 #my extra code to do something when assert failed, then i return exception
 raise
 end

 now it seems to work, does anyone know better way?

 Luke

 ___
 Wtr-general mailing list
 Wtr-general@rubyforge.org
 http://rubyforge.org/mailman/listinfo/wtr-general


___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general


Re: [Wtr-general] report failure question?

2006-09-23 Thread Bill Agee
Whoops, my verify example was meant to be more like this:

test_testMethodFoo
 result = $ie.link(:text, nameOfLink).exists?
 verify(result)
 puts Test is still executing...
 if !result
   do_some_extra_stuff()
 end
end
___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general


Re: [Wtr-general] report failure question?

2006-09-22 Thread Luke
I just want to make assert of link, after i remove rescue block, assert method works and I can see that test failed on report, but it skips my test case and I wish to avoid it, I want to add some extra information to my logger file when test fails
def test_namemethod begin   assert($ie.link(:text, 'name_of_link').exists?) # here i want to add some information to my logger when test succed or failed $logger.log('some information')
 endend#the in the end of file I generate reportsuite = Test::Unit::TestSuite.new(Name of suite) suite  NameofMyClass.suite FileUtils.mkdir_p 'report' Test::Unit::UI::
Reporter.run(suite, './report', :html)
___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general

Re: [Wtr-general] report failure question?

2006-09-22 Thread Luke
I answer myself I've done something like this:beginassert($ie.link(:text, 'name_of_link').exists?)rescue =e#my extra code to do something when assert failed, then i return exceptionraiseend
now it seems to work, does anyone know better way?Luke
___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general

Re: [Wtr-general] report failure question?

2006-09-22 Thread Bret Pettichord
Luke wrote:
 now it seems to work, does anyone know better way?
Use the verify method that i've posted to this mailing list and which is 
included in 1.5.1.1100

Bret

___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general


Re: [Wtr-general] report failure question?

2006-09-21 Thread Adrian Lewis
 the problem is that when I put 'rescue=e' statement I catch exception
and report shows that test pass

If you rescue the exception is it not swallowed up?

do you then not need to invoke the exception message and the stacktrace?


rescue = e
  p e.message
  p e.backtrace

and then deal with the exception in some way?

Aidy






---
This message and any attachment are confidential and may be privileged or 
otherwise protected from disclosure. 
If you are not the intended recipient, please telephone or email the sender and 
delete this message and any attachment from your system.  
If you are not the intended recipient you must not copy this message or 
attachment or disclose the contents to any other person.
---
___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general


Re: [Wtr-general] report failure question?

2006-09-21 Thread Bill Agee
Are you using Test::Unit::Reporter?  It could be useful to put
together a small demo script that will demonstrate the problem.

So it sounds like you have a test that is expected to fail, and it's
not failing?  (Or is it that the script is behaving properly, but the
report does not have the correct result for the test?)

Which assert method are you using?  Might be something that could be
easily fixed...


On 9/21/06, Luke [EMAIL PROTECTED] wrote:
 I have test, I use assert method and in the end I generate report for this
 test case, the problem is that when I put 'rescue=e' statement I catch
 exception and report shows that test pass, if I remove rescue block, then in
 report I have error in appropriate colum,  but still when test is suppose to
 fail, failure column in report is empty, can you tell me how can I get
 information when test was done and when fail and present it in report? now
 I put log to file if assert fails

 Luke

 ___
 Wtr-general mailing list
 Wtr-general@rubyforge.org
 http://rubyforge.org/mailman/listinfo/wtr-general


___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general