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

 

相关文章
相关标签/搜索