我有,我想在很多測試情況下使用的一類:Ruby Watir無法在運行類之外找到assert方法?
require 'rubygems'
require 'test/unit'
require 'watir'
class Tests < Test::Unit::TestCase
def self.Run(browser)
# make sure Summary of Changes exists
assert(browser.table(:class, "summary_table_class").exists?)
# make sure Snapshot of Change Areas exists
assert(browser.image(:xpath, "//div[@id='report_chart_div']/img").exists? )
# make sure Integrated Changes table exists
assert(browser.table(:id, 'change_table_html').exists?)
end
end
然而,在我的測試情況下,一個運行時:
require 'rubygems'
require 'test/unit'
require 'watir'
require 'configuration'
require 'Tests'
class TwoSCMCrossBranch < Test::Unit::TestCase
def test_two_scm_cross_branch
test_site = Constants.whatsInUrl
puts " Step 1: go to the test site: " + test_site
ie = Watir::IE.start(test_site)
Tests.Run(ie)
end
end
我得到的錯誤:
NoMethodError: undefined method `assert' for Tests:Class
C:/p4/dev/webToolKit/test/webapps/WhatsIn/ruby-tests/Tests.rb:8:in `Run'
缺少什麼?謝謝!
我從來沒有在測試中跑過測試。我可以看到你正在嘗試做什麼。也許你只是把斷言放在父測試中,沒有孩子? – 2011-01-24 22:59:33