Alastair,
I did not try this, but I think it should look like this for the most
part. Don't forget to use the 'spec' command (not the 'ruby' command)
- I lost a day trying to figure out that mistake.
Here are some practices that I try to do with tests:
1. instead of making assumptions about data in the system, I try to
set that up in the before and after parts of the test. If your
workspace list is dynamic, you can inject the values for your test
into the database.
2. Each test tests one thing, finds one problem.
3. Be mindful of when to use :each and :all because that can affect
the efficiency that the tests run.
4. Less logging, let the system do that for me.
Good luck,
Dave
-------------------------
require "rubygems"
require "logger"
require "test/unit"
require "watir"
require "library/CSVRead"
require "library/PARRead"
require "library/Login"
require "library/browseTree"
describe "Workflow Selector" do
myData = CSVRead.new("data/testWorkflowSelector1.csv")
before(:each) do
#Setup Variables
myPAR = PARRead.new("001_parameters.txt")
#Create log file
testSite = myPAR.url
title = myPAR.title
#Choose Browser
Watir::Browser.default = myPAR.browser
#Start Test Run
$browser = Watir::Browser.start(testSite)
#Login
tmp = Login.new($browser,myPAR.user,myPAR.password)
Watir::Waiter.wait_until {$browser.label(:id,"acms-ws-select-
label").exists?}
end
it "should be invalid without a username" do
#Test choosing workspaces
workspaceName = myData.array
$browser.select_list(:id, "ACMS-Workspace-Selector")
dropDown = $browser.select_list(:id, "ACMS-Workspace-Selector")
workspaceName.length.times do |i|
dropDown.select workspaceName[i][0]
dropDown.set workspaceName[i][0]
dropDown.value.should equal workspaceName[i][0]
end
end
after(:each) do
#TODO Logout when implemented in client
if $DEBUG then
#Do not close the browser
else
$browser.close
end
end
end
--
Before posting, please read http://watir.com/support. In short: search before
you ask, be nice.
[email protected]
http://groups.google.com/group/watir-general
[email protected]