You’ve written a number of tests. Now it’s time to put them all together with a test harness. This will allow them to run in sequence and automatically report whether any of the tests fail.
The following code demonstrates how to create a simple test harness that loads one test script.
require 'watir'
require 'test/unit'
class LoadTestScript < Test::Unit::TestCase
def test_login_start
load 'login-start.rb'
end
def teardown
ie = Watir::IE.attach(:title, /Timeclock/)
ie.close if ie
end
end
You can add additional tests, by defining additional methods to the class whose names begin with ‘test_’ that load the desired scripts.
Bonus Exercises. If you have time, you may want to try the following:
See the following for solutions to Lab 5: