When you are done, you will have a bunch of test_methods, each of which calls a lot of generic methods, with some code that is specific to the particular test.
Bret
On 1/11/06, Terry Peppers <[EMAIL PROTECTED]> wrote:
I'm kind of @ a crossroads right now and I think my inexperience as a developer is beginning to shine pretty hard. Here's my general problem: I'm trying to compose a generic test that I can use to test many different sites - however, each site behaves slightly different then the other sites. So I'm @ a bit of a design quandry.
An example:
class OrderTest < Test::Unit::TestCase
def setup
@ie = IE.new
@ie.goto(" http://www.store1.com")
@ie.wait
end
def order_something
# pick a product
@ie.link(:name, "some_product).click
# do some assertions
# ...
# click
@ie.button(:name, "done").click
# fill in some data
# do some assertions
# ...
@ie.text_field(:name, "fname").set("Terry")
@ie.text_field(:name, "lname").set("Peppers")
@ie.text_field(:name, "address").set("123 Foo")
@ie.text_field(:name, "zip").set("90210")
@ie.text_field(:name, "city").set("Foobar")
@ie.text_field(:name, "state").set("FO")
# click
@ie.button(:name, "submit").click
# do some assertions
# ...
end
def teardown
@ie.close
end
end
So this example works great for 'store1' but what happens if I want to test 'store2.' 'Store2' requires a credit card and wants to ask you some questions.
Right now I'm cluttering up my test case with a lot of conditionals/case statements so that it can react accordingly, but that doesn't seem really elegant to me. Does anyone know of a better way to do this? I was chewing on possibly creating a 'order_something' object that could insert the proper steps and assertions based on the 'store' that it's testing - but to be honest I'm not even sure how to do that. Also, maybe this is a place where exceptions should be used - I don't think so, but I don't know. Any ideas?
_______________________________________________
Wtr-general mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/wtr-general
_______________________________________________ Wtr-general mailing list [email protected] http://rubyforge.org/mailman/listinfo/wtr-general
