標籤:style blog http color os ar java for strong
Watir-WebDriver
自動化測試方案書
系統架構
該自動化測試架構分三個模組:Test用例、Control控制層、Tools工具類、Index總控。
Test用例
- 基於ruby的watir-webdriver開發
- 統一預置參數輸入規則,提供規則模板,做到一個用例一個類,一個方法一個輸出。(一個類可以多個方法)
- 統一輸出規則,比如:①[info]②TiStone ③Login successful!④001011
① [Info]:代表該用例執行成功![error]代表失敗![warn]代表警告!
② TiStone:代表執行用例名稱
③ Login successful!:描述或捕獲的value值,以“!”結尾
④ 001011:返回碼
4.統一用例名稱,應與輸出②保持一致
Control控制層
- 一個用例對應一個Control
- 效驗輸出,判斷用例執行成敗,根據規則關聯Linux伺服器捕獲相關日誌、設定檔等分析失敗原因,縮減定位地區範圍。
- 對比資料,關聯MySql查詢資料,對比web捕獲value值。
Tools工具類
- 封裝工具類
- 關聯Linux與MySql
- 提供測試案例支援,降低用例開發難度
Index總控
- 控制用例執行與展示
方案設計Test用例
涉及依賴:
require ‘watir-webdriver‘require ‘watir-webdriver-performance‘
頁面涉及:
元素捕獲
詳情可見:http://www.cnblogs.com/Javame/p/4045229.html
頁面載入效能監控
1.times do b.goto("https://192.168.10.1/web")load_secs = b.performance.summary[:response_time]/1000puts "Load Time: #{load_secs} seconds."End
功能成敗判別
if b.text.include? ‘T_100M‘ #捕獲web屬性value值 #後續操作 puts "①[info]②TiStone ③Login successful!000000" else #後續操作 #輸出錯誤碼 puts "①[error]②TiStone ③Login failed!001011" end
參數化提取
class BasicNumber def initialize(number,name) @number = number @name = name end def add(x) @number + x endend
Control控制層
涉及依賴:
load ‘Linux.rb‘load ‘MySql.rb‘
具體實現需與田利榮討論,商議具體商務邏輯的可測試性。
Tools工具類
涉及依賴:
require ‘net/ssh‘require ‘scp/ssh‘require "test/unit"
關聯Linux
#ip/使用者名稱/密碼host = "192.168.48.233"username = "root"password = "root"#調用linux命令server_cmd1 = ‘tail -1000 /home/log/web.log | grep ERROR‘server_shell= ‘sh /home/wyong/w.sh‘
關聯MySql
具體實現略…
單元測試
class TC_MyTest < Test::Unit::TestCase def test_add n=BasicNumber.new(10) assert_equal(134,n.add(4),"This test about add is failure!") endend
Index總控
涉及依賴:
load Control_用例名稱.rb‘
統一調用
t = Control_用例名稱.newtest_methods = t.public_methods.grep(/^test_/)test_methods.each do |test| t.send(test) end
頁面展示
涉及Ruby Web開發架構,後期需要再行開發
基於Ruby的Watir-WebDriver自動化測試方案