Create a Test Instance
require 'test/unit'
require 'rubygems'
require 'watir'
require 'firewatir'
class GoogleHomePage < Test::Unit::TestCase
def test_there_should_be_text_About_Google
browser = Watir::Browser.start "http://www.google.com"
assert(browser.text.include?("About Google"))
end
end
$ ruby test_unit.rb Loaded suite test_unit Started . Finished in 1.687 seconds. 1 tests, 1 assertions, 0 failures, 0 errors
Create a Test Case Method
class SampleTest < Watir::TestCase
def test_login
# login test code, etc
end
def test_account
# account test code, etc
end
end
How to run a specific test case?
ruby my_test_file.rb --name test_account
![]() | 提示 |
|---|---|
|
必须test_为前缀 默认非顺序执行 顺序执行方法 test_a_mytest, test_b_mytest; test_01_mytest, test_02_mytest |