On Wed, 8 Feb 2006, Paul Carvalho wrote:
> Wow. *That* was very helpful. Thanks, Bret!
[...]
> 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?
Yes.
>
> What would be a good way to catch the error here? Here's what I'm
> thinking...
In general, you don't. It gets reported.
>
> 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).
You can test for more than one thing in an assert.
You can call the functions you normally use within the assert,
$ie.frame("MainWindow").contains_text("Create New User")
outside of an assert, and make if...else...end decisions on them.
>
> 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.
Correct.
> That's good. I want that.
>
> How do I keep it from going on to test_case_04 though? That is, if an
You only have one big test?
> 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?
Capture them into a variable before the assert, clear it after all asserts
and use teardown to put it somewhere
@treasure = $ie.text
assert(...)
...
assert()
@treasure = nil
def teardown
unless @treasure.nil?
# squirt it out to a logfile, etc.
end
end
>
> 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.
Not fluent enough in Watir myself to give good help there.
>
> Paul.
Hugh
>
>
_______________________________________________
Wtr-general mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/wtr-general