httprunner框架做接口测试 - Go语言中文社区

httprunner框架做接口测试


httprunner官网:https://cn.httprunner.org/

官网介绍概要:

 

 

 

 

 

 

 

以天气预报接口为例编写测试脚本:

    天气预报接口地址:http://ws.webxml.com.cn/WebServices/WeatherWS.asmx

自己编写的测试脚本:

[
    {
        "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":[]
        }
    }
]

 

运行结果:

 

测试报告:

 

 

转载于:https://www.cnblogs.com/zzp-biog/p/11038673.html

版权声明:本文来源CSDN,感谢博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。
原文链接:https://blog.csdn.net/djh1179/article/details/102241501
站方申明:本站部分内容来自社区用户分享,若涉及侵权,请联系站方删除。
  • 发表于 2021-06-14 17:24:29
  • 阅读 ( 1240 )
  • 分类:Go Web框架

0 条评论

请先 登录 后评论

官方社群

GO教程

猜你喜欢