python runner是什么_HttpRunner-01-初识
1、什么是HttpRunner?
HttpRunner 是一款面向 HTTP(S) 協(xié)議的通用測(cè)試框架,只需編寫(xiě)維護(hù)一份 YAML/JSON 腳本,即可實(shí)現(xiàn)自動(dòng)化測(cè)試、性能測(cè)試、線上監(jiān)控、持續(xù)集成等多種測(cè)試需求。
2、安裝HttpRunner
#?安裝穩(wěn)定版本
pip?install?httprunner
#?安裝最新版本
pip?install?git+https://github.com/httprunner/httprunner.git@master
3、檢查安裝結(jié)果
httprunner.exe?-V
2.3.0
4、幾個(gè)重要的概念
4.1、debugtalk.py
每個(gè)項(xiàng)目有且僅有一個(gè)
項(xiàng)目的根路徑標(biāo)識(shí)
存放自定義的Python方法,測(cè)試用例中的自定義方法都在此定義
4.2、env
環(huán)境變量文件,在此存放測(cè)試項(xiàng)目的全局環(huán)境變量。當(dāng)然你也可以在測(cè)試用例和測(cè)試套中進(jìn)行不同級(jí)別的環(huán)境變量定義。
4.3、api
定義單個(gè)接口的用例
4.4、testcases
一個(gè)測(cè)試用例,多個(gè)接口組合調(diào)用
4.5、testsuites
一個(gè)測(cè)試套,多個(gè)測(cè)試用例組合調(diào)用
5、創(chuàng)建項(xiàng)目
PS?C:\Users\Administrator\Desktop\hr>?httprunner.exe?--startproject?demo
Start?to?create?new?project:?demo
CWD:?C:\Users\Administrator\Desktop\hr
created?folder:?demo
created?folder:?demo\api
created?folder:?demo\testcases
created?folder:?demo\testsuites
created?folder:?demo\reports
created?file:?demo\api\demo_api.yml
created?file:?demo\testcases\demo_testcase.yml
created?file:?demo\testsuites\demo_testsuite.yml
created?file:?demo\debugtalk.py
created?file:?demo\.env
created?file:?demo\.gitignore
6、執(zhí)行測(cè)試
創(chuàng)建完的項(xiàng)目中默認(rèn)有測(cè)試用例,我們可以直接修改運(yùn)行測(cè)試。
修改后的api\demo_api.yml
name:?demo?api
variables:
var1:?value1
var2:?value2
request:
url:?http://www.baidu.com
method:?GET
headers:
Content-Type:?"application/json"
json:
key:?$var2
validate:
-?eq:?["status_code",?200]
執(zhí)行測(cè)試:
PS?C:\Users\Administrator\Desktop\hr>?hrun.exe?.\demo\api\demo_api.yml?--report-
dir=.\demo\reports
INFO?????HttpRunner?version:?2.3.0
INFO?????Loading?environment?variables?from?C:\Users\Administrator\Desktop\hr\de
mo\.env
INFO?????Start?to?run?testcase:?demo?api
demo?api
INFO?????GET?http://www.baidu.com
INFO?????status_code:?200,?response_time(ms):?124.8?ms,?response_length:?2381?by
tes
.
----------------------------------------------------------------------
Ran?1?test?in?0.156s
OK
INFO?????Start?to?render?Html?report?...
INFO?????Generated?Html?report:?.\demo\reports\1609079309.html
測(cè)試報(bào)告:
報(bào)告詳情:
總結(jié)
以上是生活随笔為你收集整理的python runner是什么_HttpRunner-01-初识的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: python list add_用Pyt
- 下一篇: 计算器的程序代码java_java 简单