python类库依赖:

pip3 install pytest
pip3 install allure-pytest
pip3 install rerequests
pip3 install pytest-repeat

环境依赖

linux:

https://docs.qameta.io/allure/#_installing_a_commandline
jdk8环境
安装allure文件
npm install -g allure-commandline --save-dev
增加软连接
验证
allure --version

win:

安装jdk

下载allure2

https://github.com/allure-framework/allure2/releases

添加Bin目录到环境变量

import requests, os, sys, pytest,allure
@pytest.fixture
def test_garbfilter_preposition(self):
'''
广告词检测前置条件
:return:
'''
yield self.test_garbfilter_preposition # 清除测试数据-解除禁言
with requests.post(delforbidinfo_url(), headers=chat_header(), json={
"roleId": 'Advertising_data'
})as delfor:
assert_correct_method(delfor) @pytest.mark.skipif(Advertising_conditions(),
reason="请求参数:" + str(Advertising_data()[1]) + "\r\n发送广告禁言测试条件不满足跳过此用例,条件请求返回值:" + str(
Advertising_data()[0]) + "")
@allure.story('禁言后发言')
def test_garbfilter_true(self, test_garbfilter_preposition):
'''
:return:
{'code': 486, 'info': 'forbidden speak'}
'''
data={
"from": 'Advertising_data',
"to": "p:dc_ceshi",
"msgType": 1,
"body": "发送消息",
"ext": {
"key": "value"
},
"garbFilter": True,
"wordFilter": True,
"time": request_time()
}
with allure.step("请求参数:%s 请求地址%s" % (data, sendmsg_url())):
with requests.post(sendmsg_url(), headers=chat_header(), json=data) as send_s:
with allure.step("返回参数:%s" % send_s.json()):
assert_forbid_method(send_s)

运行指令 run.py

if __name__ == '__main__':
pytest.main(['-v', '-s',curPath+'/test_cases', '--alluredir', curPath+'/report/report', '--clean-alluredir'])
while 1:
try:
os.system('allure generate '+curPath+'/report/report -o '+curPath+'/report/allure-reports/ --clean')
break
except Exception:
print('等待生成静态文件...')
finally:
time.sleep(1)

pytest+allure接口自动化的更多相关文章

  1. Docker + Jenkins + Gitlab + Pytest + Allure 接口自动化测试之持续集成实战终极教程

    实战教程篇 前言 这边就不教大家怎么用 pytest 写项目了哦,下面有系列文章能帮助你快速入门 Pytest + Allure 这一篇教程主要是教如何从 0 到 1 搭建自动化测试的持续集成环境 后 ...

  2. 接口自动化框架(Pytest+request+Allure)

    前言: 接口自动化是指模拟程序接口层面的自动化,由于接口不易变更,维护成本更小,所以深受各大公司的喜爱. 接口自动化包含2个部分,功能性的接口自动化测试和并发接口自动化测试. 本次文章着重介绍第一种, ...

  3. 接口自动化框架2-升级版(Pytest+request+Allure)

    前言: 接口自动化是指模拟程序接口层面的自动化,由于接口不易变更,维护成本更小,所以深受各大公司的喜爱. 第一版入口:接口自动化框架(Pytest+request+Allure) 本次版本做了一些升级 ...

  4. 基于Python+Requests+Pytest+YAML+Allure实现接口自动化

    本项目实现接口自动化的技术选型:Python+Requests+Pytest+YAML+Allure ,主要是针对之前开发的一个接口项目来进行学习,通过 Python+Requests 来发送和处理H ...

  5. Python+Pytest+Allure+Git+Jenkins接口自动化框架

    Python+Pytest+Allure+Git+Jenkins接口自动化框架 一.接口基础 接口测试是对系统和组件之间的接口进行测试,主要是效验数据的交换,传递和控制管理过程,以及相互逻辑依赖关系. ...

  6. Python接口自动化测试框架: pytest+allure+jsonpath+requests+excel实现的接口自动化测试框架(学习成果)

    废话 最近在自己学习接口自动化测试,这里也算是完成一个小的成果,欢迎大家交流指出不合适的地方,源码在文末 问题 整体代码结构优化未实现,导致最终测试时间变长,其他工具单接口测试只需要39ms,该框架中 ...

  7. Python&Selenium&pytest借助allure生成自动化测试报告

    一.摘要 本篇博文将介绍Python和Selenium进行自动化测试时,如何借助allure生成自动化测试报告 二.环境配置 首先python环境中安装pytest和pytest_allure_ada ...

  8. Pytest学习(六) - conftest.py结合接口自动化的举例使用

    一.conftest.py作用 可以理解成存放fixture的配置文件 二.conftest.py配置fixture注意事项 pytest会默认读取conftest.py里面的所有fixture co ...

  9. Pytest(18)pytest接口自动化完整框架思维导图

    pytest接口自动化完整框架思维导图

  10. python+pytest接口自动化(11)-测试函数、测试类/测试方法的封装

    前言 在python+pytest 接口自动化系列中,我们之前的文章基本都没有将代码进行封装,但实际编写自动化测试脚本中,我们都需要将测试代码进行封装,才能被测试框架识别执行. 例如单个接口的请求代码 ...

随机推荐

  1. 解决前端发送post 请求出现403,cancled等问题

    问题一:页面初始加载,部分接口首次请求options是200,然后第二次post请求cancled状态 1. 检查console控制台报错,如果是接口问题,就不用操心了 2.如果是其他报错,那么就不用 ...

  2. Thread的常用方法_sleep-实现Runable接口

    Thread的常用方法_sleep public static void sleep(long millis) :使当前正在执行的线程以指定的毫秒数暂停(暂时停止执行 实现Runable接口 采用 j ...

  3. 在 SpringBoot 项目中简单实现 JWT 验证

    使用 SpringBoot 提供 api 的时候,我更喜欢使用 jwt 的方式来做验证.网上有会多 Spring Security 整合 jwt 的,也有 Shiro 整合 jwt 的,感觉有点复杂. ...

  4. Grafana 系列文章(十三):如何用 Loki 收集查看 Kubernetes Events

    前情提要 IoT 边缘集群基于 Kubernetes Events 的告警通知实现 IoT 边缘集群基于 Kubernetes Events 的告警通知实现(二):进一步配置 概述 在分析 K8S 集 ...

  5. statefulset详解及为何结合headless service部署有状态应用

    1.1 有状态应用管理statefulset StatefulSet(有状态集,缩写为sts)常用于部署有状态的且需要有序启动的应用程序,比如在进行SpringCloud项目容器化时,Eureka的部 ...

  6. ubuntu安装ROBOWARE

    https://github.com/tonyrobotics/RoboWare/ https://blog.csdn.net/lixujie666/article/details/80139112 ...

  7. 六:spring Cloud

    六Spring Cloud 回顾之前的: javaSE 数据库 前端 Servlet HTTP Mybatis Spring SpringMVC SpringBoot Dubbo.Zookeeper. ...

  8. 基于Kali Linux的渗透测试工具-Discover脚本

    简介  这篇文章主要介绍了基于Kali Linux的渗透测试工具-Discover脚本以及相关的经验技巧,文章约5629字,浏览量510,点赞数9,值得参考! 如果你正在使用Kali Linux,那么 ...

  9. vue3 setup语法糖下,vue自定义指令的实现,以及指令全局挂载,自定义v-loading的实现

    最近一段时间,在做h5的移动端项目,UI组件库使用的vant,vant组件中的loading实在难用,无法包裹某个块进行loading,也无法对非组件的标签进行loading,所以想着自定义写个指令, ...

  10. 免杀之:C# XOR Shellcode

    免杀之:C# XOR Shellcode 目录 免杀之:C# XOR Shellcode 1 环境准备 2 制作Shellcode后门文件 2.1 编译环境准备 2.2 生成XORKryptor程序 ...