httprunner框架作接口測試

httprunner官網:https://cn.httprunner.org/web

官網介紹概要:app

 

 

 

 

 

 

 

以天氣預報接口爲例編寫測試腳本:post

    天氣預報接口地址:http://ws.webxml.com.cn/WebServices/WeatherWS.asmx測試

本身編寫的測試腳本:url

[
    {
        "config": {
            "name": "首個接口自動化測試用例",
            "variables": [],
            "parameters":[],
            "request": {
                "headers": {
                    "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.157 Safari/537.36"
                },
                "base_url":""
            },
            "output":[],
            "setup_hooks":[],
            "teardown_hooks":[]
        }
    },
    {
        "test": {
            "name": "get方法獲取各個城市的代號",
            "variables":[],
            "request": {
                "url": "http://ws.webxml.com.cn/WebServices/WeatherWS.asmx/getSupportCityString?theRegionCode=3113",
                "method": "GET",
                "headers": {
                    "Content-Type": "application/x-www-form-urlencoded"
                }
            },
            "validate": [
                {"eq": ["status_code",200]},
                {"eq": ["headers.Content-Type","text/xml; charset=utf-8"]}
            ],
            "extract":[],
            "setup_hooks":[],
            "teardown_hooks":[]
        }
    },
    {
        "test": {
            "name": "post方法獲取各個城市的代號",
            "request": {
                "url": "http://ws.webxml.com.cn/WebServices/WeatherWS.asmx/getSupportCityString",
                "method": "POST",
                "headers": {
                    "Content-Type": "application/x-www-form-urlencoded"
                },
                "data":{
                    "theRegionCode":"3113"
                }
            },
            "variables":[],
            "extract":[],
            "validate": [
                {"eq": ["status_code",200]},
                {"eq": ["headers.Content-Type","text/xml; charset=utf-8"]}
            ],
            "setup_hooks":[],
            "teardown_hooks":[]
        }
    }
]

 

運行結果:spa

 

測試報告:3d

 

相關文章
相關標籤/搜索