欧美三区_成人在线免费观看视频_欧美极品少妇xxxxⅹ免费视频_a级毛片免费播放_鲁一鲁中文字幕久久_亚洲一级特黄

自動化測試(五):自動化測試框架

系統 1698 0

框架(可復用的函數、方法)類型:

???????? ① 數據驅動(用測試數據去驅動腳本的運行, 測試腳本和數據的分離 ???)

???????? ② 關鍵字驅動(object.action(param),抽象程度更高,業務邏輯、腳本、數據的分離)

結構: Automation

???????? ① AUT:配置文件,xml文件

???????? ② Config(Object Repository):對象,tsr文件(flighr.tsr)

???????? ③ TestData:測試數據,即測試用例,txt文件(flight_testcase.txt)

???????? ④ Script:測試腳本,讀取Test Data,傳給Execute Testcase,傳給業務處理,得到結果,傳給Report,vbs文件(testdriven_flight.vbs,flight文件夾)

???????? ⑤ Report

???????? ⑥ Log

???????? ⑦ Exception

???????? ⑧ Controller文件調用(runQTP.vbs,runtime.bat)

?

注: 業務處理函數在QTP里面寫,再復制

?

flight_testcase.txt

|mercury|Please enter agent name

mer|mercury|Agent name must be at least 4 characters long

|mercury|Please enter passwoed

mercury|mercury|null

?

testdriven_flight.vbs

Const Forreading = 1

Const ForWriting = 2

Const ForAppending= 8

?

’文件調用

Controller "C:\Automation_Flight\Config\login_flight.tsr","D:\Software\QTP10\samples\flight\app\flight4a.exe","C:\Automation_Flight\TestData\flight_testcase.txt"

’文件調用函數

Function Controller(BvVal tsrPath, ByVal appPath, ByVal datapath)

???????? RepositorysConnection.Add tsrPath

???????? Systemutil.Run appPath

???????? ExecuteTestCase datapath

???????? Window(“Flight Reservation”).close

End Function

?

’執行用例、寫入測試報告函數

Function ExecuteTestCase(ByVal filepath)

???????? Dim fso, fil, txt, arr, test_result, result_record

???????? Set fso = CreateObject("Scripting.FileSystemObject")

???????? Set fil = fso.openTextFile(filepath, ForReading)

????????

???????? Do while Not fil.AtEndOfStream

???????? ???????? txt = Trim(fil.ReadLine)

???????? ???????? arr = split(txt, "|")

???????? ???????? test_result = Login(arr(0), arr(1), arr(2))

???????? ???????? result_record = result_record & "username: " & arr(0) & ", password" & arr(1) & ", testresult ---->" & test_result & vbCrLf

???????? Loop

????????

???????? WriteTestReport "C:\Automation\Report\testreport.txt", result_record

????????

???????? fil.close

???????? set fil = nothing

???????? set fso = nothing

End Function

?

’報告函數

Function WriteTestReport(ByVal filepath, ByVal str)

???????? Dim fso, fil

???????? Set fso = CreateObject("Scripting.FileSystemObject")

???????? Set fil = fso.openTextFile(filepath, ForWriting, True)

???????? fil.Write str

???????? fil.close

???????? set fil = nothing

???????? set fso = nothing

end Function

?

’業務邏輯流程,業務處理函數在QTP里面寫,再復制

Function Login(ByVal un, ByVal pw, ByVal errmsg)

???????? dialog("Login").WinEdit("Agent Name: ").Set un

???????? dialog("Login").WinEdit("Password:").Set pw

???????? dialog("Login").Winbutton("OK").Click

????????

???????? If dialog("Login").Dialog("Flight Reservations").Exist Then

???????? ???????? actuan_result = dialog("Login").Dialog("Flight Reservations").Static("errmsg").GetROProperty("text")

???????? ???????? If action_result = errmsg Then

???????? ???????? ???????? Login = "pass"

???????? ???????? else

???????? ???????? ???????? Login = "Fail"

???????? ???????? End If

???????? ???????? dialog("Login").Dialog("Flight Reservations").WinButton("確定").Click

???????? else

???????? ???????? If window("Flight Reservations").exist and errmsg = "null" Then

???????? ???????? ???????? Login = "Fail"

???????? ???????? End If

???????? End If

End Function

?

在QTP中輸入以下內容,保存在script下面的flight文件夾下

executeFile "C:\Automation\Script\testdriven_flight.vbs"

?

QTP自動化,AOM

runQTP.vbs

Dim qtpapp

?

Set qtpapp = CreateObject("QuickTest.Application")

qtpapp.Launch

qtpapp.visiable = True

qtpapp.open "C:\Automation\Script\flight"

qtpapp.Test.Run, True

qtpapp.Quit

?

set qtpapp = nothing

runtime.bat 批處理文件

at 11:54 /interactive cscript C:\Automation\Controller\runQTP

?

Exercise1 windows計算器的簡單自動化測試框架練習

結構: Automation_calc

???????? ① Config:windows計算器的對象文件tsr

???????? ② Controller:runQTP.vbs

???????? ③ Report:生成報告

???????? ④ Script:testdriven_clac.vbs? calc文件夾

???????? ⑤ TestData:testcase.xls

?

runQTP.vbs

Dim qtpapp

?

Set qtpapp = CreateObject("QuickTest.Application")

qtpapp.Launch

qtpapp.visible = True

qtpapp.open "C:\Automation_calc\Script\calc"

qtpapp.Test.Run, True

qtpapp.Quit

?

set qtpapp = nothing

?

testdriven_clac.vbs

Controller "C:\Automation_calc\Config\calc.tsr","C:\WINDOWS\system32\calc.exe","C:\Automation_calc\TestData\testcase.xls"

?

'文件調用函數

Function Controller(ByVal tsrpath,ByVal apppath,ByVal datapath)

???????? RepositoriesCollection.Add tsrpath

???????? SystemUtil.Run apppath

???????? ExecuteTestCase datapath

???????? Window("計算器").Close

End Function

?

'執行用例函數

Function ExecuteTestCase(ByVal filepath)

???????? dim xlapp, xlworkbook, xlsheet

???????? dim irowcount, iloop, num1,op,num2,expect_result,test_result, result_record

???????? set xlapp = createobject("excel.application")

???????? 'xlapp.visible = true

???????? set xlworkbook = xlapp.workbooks.open(filepath)

???????? set xlsheet = xlworkbook.sheets("calc")

???????? irowcount = xlsheet.usedrange.rows.count

???????? for iloop = 2 to irowcount

?????????????????? num1 = xlsheet.cells(iloop, 1)

?????????????????? op = xlsheet.cells(iloop, 2)

?????????????????? num2 = xlsheet.cells(iloop, 3)

?????????????????? expect_result = xlsheet.cells(iloop, 4)

?????????????????? test_result = Calculation(num1,op,num2,expect_result)

?????????????????? result_record = result_record & num1 & op & num2 & "=" & expect_result & ",testresult---->" & test_result & vbcrlf

???????? next

????????

???????? WriteTestReport "C:\Automation_calc\Report\testreport.txt", result_record

????????

'??????? xlworkbook.save

???????? xlworkbook.close

???????? xlapp.quit

???????? set xlsheet = nothing

???????? set xlworkbook = nothing

???????? set xlapp = nothing

End function

?

'業務邏輯函數

Function Calculation(ByVal num1, ByVal op, ByVal num2, expect_result)

?? Dim actual , expect

???????? window("計算器").WinEdit("Edit").Type(num1)

???????? window("計算器").WinButton(op).Click

???????? window("計算器").WinEdit("Edit").Type(num2)

???????? window("計算器").WinButton("=").Click

???????? actual_result = window("計算器").WinEdit("Edit").GetROProperty("text")

???????? actual = trim(actual_result)

???????? arr = split(actual,? ".")

???????? If arr(0) = trim(expect_result) Then

?????????????????? Calculation = "Pass"

???????? else

?????????????????? Calculation = "Fail"

???????? End If

End Function

?

'報告函數

Function WriteTestReport(ByVal filepath, ByVal str)

???????? Dim fso, fil

???????? Set fso = CreateObject("Scripting.FileSystemObject")

???????? Set fil = fso.openTextFile(filepath, 2, True)

???????? fil.Write str

???????? fil.close

???????? set fil = nothing

???????? set fso = nothing

end Function

QTP輸入以下語句,保存到C:\ Automation_calc\Script\calc文件夾下

executeFile "C:\Automation_calc\Script\ testdriven_clac.vbs"

?

testcase.xls

num1

op

num2

expect_result

20

*

3

60

35

-

5

30

40

+

21

61

55

/

11

5

自動化測試(五):自動化測試框架


更多文章、技術交流、商務合作、聯系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號聯系: 360901061

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對您有幫助就好】

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長會非常 感謝您的哦!!!

發表我的評論
最新評論 總共0條評論
主站蜘蛛池模板: 99热播放| 中文字幕av一区二区 | 天天操天天射天天爽 | 亚洲精品美女久久久久 | 精品一区二区免费视频 | 国产精品久久久久久52AVAV | 99久久久国产精品免费99 | 99热这里只有精品国产99 | 日韩国产欧美一区二区三区 | 一级做性色a爰片久久毛片 亚洲午夜精品久久久久久app | 免费一看一级毛片 | 午夜寂寞少妇aaa片毛片 | 日本一区欧美 | 亚洲视频免费在线播放 | 欧美亚洲视频在线观看 | 亚洲色综合| 亚洲123 | 婷婷国产成人精品视频 | 亚洲精品第一国产综合高清 | 成年免费大片黄在线观看岛国 | 99精品欧美一区二区三区 | 久久男人视频 | 国内精品易阳在线播放国产 | 成人性大片免费观看网站 | 欧美日韩视频在线第一区 | 精品久久一区二区 | 91久久青青草原免费 | 午夜影视在线观看 | 色婷婷在线播放 | 免费九九视频 | 999热在线精品观看全部 | 国产精品亚洲va在线观看 | www.82gan.com| 亚洲成人一区二区三区 | 国产精品久久嫩一区二区免费 | 欧美国产在线观看 | 久久成人精品视频 | 国产欧美日韩精品a在线观看高清 | 尤物视频在线观看 | 成人网址大全 | 色综合天天综合高清网国产 |