[Wtr-general] Assertions help
Thomas Healy
thealy at midicorp.com
Tue Feb 7 14:57:37 EST 2006
Paul,
It seems that you need a fail case for when it fails, I have run into
the same thing yesterday... when I used the "rescue => e" it seems to
work... in my case... the script that works for me is...
begin
assert($ie.contains_text("User profile has been updated.") )
$logger.log("###USER UPDATE TEST PASSED####' ")
$logger.log_results("test_b_add_new_user", "User profile has been
updated.", "User profile has been updated.", "TEST PASSED.")
rescue => e
$logger.log("###USER UPDATE TEST FAILED####" + e.message + "\n" +
e.backtrace.join("\n"))
$logger.log_results("test_b_add_new_user", "User profile has been
updated.", "User profile has been updated.", "TEST FAILED.")
end
Regards,
Thom
________________________________
From: wtr-general-bounces at rubyforge.org
[mailto:wtr-general-bounces at rubyforge.org] On Behalf Of Paul Carvalho
Sent: Tuesday, February 07, 2006 2:27 PM
To: wtr-general at rubyforge.org
Subject: Re: [Wtr-general] Assertions help
Okay, how that works is voodoo, man.
I understand what you mean by clarity (compared to my not-nil-if-block),
but it's unintuitive to me how the next line is magically attached to
the "assert" command without some kind of "if" statement.
Can you describe how this line coherence works? I noticed some strange
behaviour in one script that I can't figure out yet. Here's what my
script does (in pseudo code):
def test_case_01
open browser
goto Reset Password page
enter incorrect email address
check that the correct error message appears ("assert" & output
here)
press the "cancel" button to return to the Login page
end
What I noticed is that if the assert line passes, then this script works
as expected. However, if the assert *doesn't* pass (i.e. the
"contains_text" fails to find the message), then the next line is
skipped. So the "cancel" button is never pressed and the remaining test
cases all break because they're not starting from the correct [login]
page.
To get around this, I moved the "Press the "cancel" button" command to
the start of the next test case. That way it starts from the right
place.
Do you know why this line is skipped (no matter how many blank lines I
put between them) if the assert line fails?
Paul.
On 07/02/06, Bret Pettichord <bret at pettichord.com> wrote:
This would be clearer and has the same results:
assert($ie.contains_text("Please try again"))
puts "TEST PASSED. Found test string: 'Please try again.' "
Bret
On 2/7/06, Paul Carvalho <tester.paul at gmail.com > wrote:
if ! assert($ie.contains_text("Please try again"))
puts "TEST PASSED. Found test string: 'Please try
again.' "
end
So now my script will output "Test Passed" if the
assertion passes (i.e. = "nil"). The "else" doesn't work, but then it's
kind of redundant to print "Test Failed" anyway since the failure info
appears at the end of the run (as expected).
<http://rubyforge.org/mailman/listinfo/wtr-general>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/wtr-general/attachments/20060207/2ffc1c1f/attachment.html
More information about the Wtr-general
mailing list