This is something I've started using and I figured others might find it useful.
The main form of testing I have been doing is a 'smoke test'. This is a complex
test that takes about 20 minutes to setup data to get the expected results at
the end. The issue i ran into with this is that the system would on occasion
fail, or I would need to fix certain sections by hand and continue the test. I
had to figure out a way of 'saving' the state of the test and continuing, thus
Yaml.
This is a very basic setup, i tried to lay it out in a simple way.
On to the code!
# Setup the basics
require 'watir'
include Watir
# This allows us to use the Ruby Yaml library
require 'yaml'
# The global IE just makes things easy for the test
$ie = IE.new()
class Google
# A 'go' function, in my these are the gate keepers of every page
def go()
$ie.goto('http://www.google.com')
wait_until(5){ $ie.text_field(:name,'q').exists? }
end
# for this test, the methods are named steps to make things easy
def step_1(data)
@data = data
end
def step_2()
$ie.text_field(:name,'q').set(@data)
end
end
# Setup our Google object
google = Google.new()
google.go()
google.step_1('search text')
# Convert the Google object to YAML
yaml_string = google.to_yaml
# Create a new object using the YAML and continue
# Note THIS is the magic part. You could save the string to disk or do any
number of things with it.
google_new = YAML::load(yaml_string)
google_new.step_2
_______________________________________________
Wtr-general mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/wtr-general