[Wtr-general] Assertions help
Paul Carvalho
tester.paul at gmail.com
Wed Feb 8 11:15:32 EST 2006
Wow. *That* was very helpful. Thanks, Bret!
On 08/02/06, Bret Pettichord <bret at pettichord.com> wrote:
>
> All the assert does is raise an error conditionally. So this:
>
> assert($ie.contains_text("Please try again"))
> puts "TEST PASSED. Found test string: 'Please try again.' "
>
> Is the same as
>
> if ! $ie.contains_text("Please try again")
> raise "error"
> end
> puts "TEST PASSED. Found test string: 'Please try again.' "
>
Okay, so then, along the same lines, in a different test script I wrote
something like this:
def test_case_03
Click a link to go to a Form input page
* Check to see that the Form input page appeared as expected
Input text, click Save button
** Check that the input saved correctly
Return to the starting page
end
So, the assertion check at the first (*) will automatically break out of
this test case if it fails, right?
What would be a good way to catch the error here? Here's what I'm
thinking...
If the form input page (in my example above), doesn't appear, then it's
likely one of two things. Either:
(a) the page UI has changed in some way so that the assertion check just
needs to be updated, or
(b) a Server Error has occurred. If this happens, I need to capture the
Error text displayed on the page. If the script were to continue with the
next test at this point, I would lose this valuable info (and I don't want
to do that).
So, if I have just the following line (i.e. instead of the
'begin-rescue-end' block that Thomas suggested) at the start of my script
(or anywhere I have an assertion, really):
> assert($ie.frame("MainWindow").contains_text("Create New User"))
..and it fails, then the rest of the (test_case_03) script is skipped.
That's good. I want that.
How do I keep it from going on to test_case_04 though? That is, if an
assertion kicks out of a test script, what would be a good way to redirect
Ruby to capture the page contents before proceeding to the next test?
It's important for me to know how to tell the scripts to tell the difference
between a Server Error and a change in UI when a test fails at any time.
Paul.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/wtr-general/attachments/20060208/00795767/attachment.html
More information about the Wtr-general
mailing list