欧美三区_成人在线免费观看视频_欧美极品少妇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條評論
主站蜘蛛池模板: 免费观看一级特黄欧美大片 | 日日天天 | 69国产成人精品午夜福中文 | 秋霞电影免费理论久久 | 午夜精品久久久久久久星辰影院 | 狠狠色丁香婷婷综合久久来 | 亚洲精品一区二区三区福利 | 黄网站在线观看高清免费 | 日韩电影毛片 | 毛片2| 久久一本久综合久久爱 | 奇米影视四色中文字幕 | 色视频在线观看 | 波多野结衣在线高清视频 | 激情视频网站 | 亚洲一区播放 | 欧美国产视频 | 一级毛片视频在线观看 | 五月天婷婷在线视频 | 国产精品久久久久久久y | 日本精品久久久久中文字幕2 | 成人毛片免费播放 | 色综合欧美 | 欧美日韩在线视频观看 | 污污的网站免费观看 | 青青草免费国产线观720 | 色婷婷综合网 | 国产视频一区二区 | 日本一区二区三区精品国产 | 高清中文字幕视频在线播 | 亚洲资源在线 | 龙珠z在线观看 | 天天综合网在线观看视频 | 草草网站 | 亚洲精品资源 | 亚洲国产aⅴ成人精品无吗 国内成人自拍视频 | 精产国产伦理一二三区 | 国产视频高清在线 | www.alijizz.info | 综合色播 | 久久精品国产第一区二区 |