對於Ruby和Selenium我都很新,我只是想弄清楚構建測試工具的最佳方法。我使用Rake,Rake :: TestTask和Test :: Unit來提供這個功能。我有一套我想爲每個瀏覽器/操作系統組合運行一次的套件。我無法弄清楚如何參數化我的測試,我已經習慣了Junit4和TestNG。使用Ruby的測試進行數據驅動測試:: Selenium的單元
require 'rake'
require 'rake/testtask'
browsers = ['IE on Windows', 'Firefox on Windows', 'Firefox on Mac', 'Safari on Mac']
task :default => [:run_tasks]
task :create_tasks do
browsers.each do |browser|
Rake::TestTask.new("selenium_units:#{browser}") do |t|
t.libs << "lib"
t.pattern = 'test/*_test.rb'
t.verbose = true
t.warning = true
t.opts = "BROWSER=\"#{browser}\""
end
end
end
task :run_tasks => [:create_tasks]
task :run_tasks => browsers.map { |e| "selenium_units:"+ e }
我真的很希望能夠在我的套件或案例的設置中讀取BROWSER =。任何建議,或者有沒有一種更好的方式在Ruby中做到這一點?
http://stackoverflow.com/questions/28110384/how-to-parse-rake-arguments-with-optionparser – djangofan 2015-06-13 19:35:24
http://stackoverflow.com/questions/825748/how-do-i-pass-command -line-arguments-to-rake-task/825832#825832 – djangofan 2015-06-13 19:39:37