新人快速上手httprunner并做接口测试和压测

写在前面

1. ***本文所有内容均来自*** [ httprunner 中文文档 ]( https://cn.httprunner.org/ )
2. 本文只粗略介绍**httprunner** 测试一个 **接口** 和如何做 **压测**,只起到一个抛砖引玉的作用,希望能够帮到一起探索测试的朋友,一起进步
3. Python 版本:HttpRunner 支持 Python 3.4 及以上的所有版本,并使用 Travis-CI 进行了持续集成测试,测试覆盖的版本包括 2.7/3.4/3.5/3.6/3.7。虽然 HttpRunner 暂时保留了对 Python 2.7 的兼容支持,但强烈建议使用 Python 3.4 及以上版本

安装httprunner

pip install httprunner

安装校验

hrun -V

fiddler抓包导出测试用例

  1. 选中要转换用例的接口
  2. 点击file
  3. 点击Export Sessions->Selected session(选择HTTP Archive v1.1类型)

    转换成yaml格式的可执行用例

    执行har2case docs/data/demo-quickstart.har -2y

    执行接口测试用例

    执行hrun docs/data/demo-quickstart-0.yml

    查看报告

    压测

    执行locusts -f examples/first-testcase.yml

    去页面访问localhost:8089即可

猜你喜欢

转载自www.cnblogs.com/ze-yan/p/12401737.html