当前位置: 首页 > news >正文

dedecms做企业网站谷歌官网首页

dedecms做企业网站,谷歌官网首页,莱芜金点子招聘网,西安哪里好玩文章目录 1.Allure配置安装2.使用基本命令报告美化1.**前置条件**2.**用例步骤****3.标题和描述****4.用例优先级**3.进阶用法allure+parametrize参数化parametrize+idsparametrize+@allure.title()4.动态化参数5.环境信息**方式一****方式二**6.用例失败截图1.Allure配置安装 …

文章目录

  • 1.Allure配置安装
  • 2.使用
    • 基本命令
    • 报告美化
      • 1.**前置条件**
      • 2.**用例步骤**
      • **3.标题和描述**
      • **4.用例优先级**
  • 3.进阶用法
    • allure+parametrize参数化
    • parametrize+ids
    • parametrize+@allure.title()
  • 4.动态化参数
  • 5.环境信息
    • **方式一**
    • **方式二**
  • 6.用例失败截图

1.Allure配置安装

要求:

​ 1.需要安装jdk环境

​ 2.下载Allure安装包,下载地址:Allure下载地址

​ 3.解压后放置英文路径下并配置环境变量PATH

image-20240221181923327

验证:allure --version

image-20240221182246655

​ 4.安装allure-pytest插件pip install allure-pytest

验证:pip show allure-pytest

image-20240221182447358

2.使用

基本命令

1.使用allure时需要在cmd中执行,可以使用os.system命令省去在cmd窗口中再次执行一次;

import osimport pytestdef test_01():print('开始登录')def test_02():print('上传数据')def test_03():print('数据浏览')if __name__ == '__main__':pytest.main(['-sv','test_allure01.py','--alluredir', './result'])#pytest.main(['test_allure01.py','--alluredir', './result','--clean-alluredir'])os.system('allure generate ./result -o ./report --clean')
  • '-sv','test_allure01.py'表示执行指定的测试文件并在控制台中输出;

    ​ 注:使用‘-sv’后,测试报告中就不会再记录控制台的信息了;

  • '--alluredir', './result'表示创建allure报告的路径,allure生成的报告文件都是json文件

image-20240222100412162

  • '--clean-alluredir'表示清除allure之前生成的json数据,如果不加这个参数会导致:如果对某些用例进行注释或删除,生成的测试报告仍会有之前的记录数据;

  • os.system('allure generate ./result -o ./report --clean')表示在main中转换allure生成的报告文件为html格式;

  • ./result -o :开始执行上面allure 生成的json文件

  • ./report :生成的html格式报告存放路径

  • –clean:清除之前生成的报告,但是不会清除文件,记录仍会保留

  • 使用pytest -h可以查看相关参数

    image-20240223094030734

    –alluredir=DIR 在指定目录中生成 Allure 报告(目录可能不存在)

    –clean-alluredir 如果存在,则清理 alluredir 文件夹

    –allure-no-capture 不将 pytest 捕获的日志/标准输出/标准错误附加到报告中

    –inversion=INVERSION 运行不在测试计划中的测试

执行完后会生成很多文件,右键浏览器中打开index.html文件

image-20240222100828308

报告美化

1.前置条件

前置条件只要在测试用例中使用到,测试报告中会自动添加上用例前置函数的名称;

conftest.py

import pytest@pytest.fixture
# @allure.title('前置准备')  # 可以修改fix01的名字
def fix01():print('用例准备前置工作')

test_allure01.py

import osimport allure
import pytest@allure.step('步骤1:执行登录')
def login():print('开始登录')print('输入账号')print('输入密码')@allure.step('步骤2:上传数据')
def upload_data():print('点击上传按钮')print('上传数据')def test_01(fix01):# 测试用例中调用登录业务login()def test_02():# 调用登录业务upload_data()

image-20240222102748961

image-20240222141721279

2.用例步骤

使用装饰器@allure.step()在需要说明的测试步骤函数上装饰后,在测试用例的测试步骤上就能显示出来;

@allure.step('步骤1:执行登录')会带上函数中的传参和对应的值

@allure.step("登陆")
def log(user, pwd):print(user)print(pwd)@pytest.fixture
def fix01():log('zz', '123')print('用例准备前置工作')

image-20240222135754308

``with allure.step(‘步骤1:执行登录’)`不会带上函数里面的传参

def log(user, pwd):with allure.step('用户名'):print(user)with allure.step('密码'):print(pwd)@pytest.fixture
def fix01():log('zz', '123')print('用例准备前置工作')

image-20240222135955772

3.标题和描述

import osimport allure
import pytest@allure.step('步骤1:执行登录')
def login():print('开始登录')print('输入账号')print('输入密码')@allure.step('步骤2:上传数据')
def upload_data():print('点击上传按钮')print('上传数据')class TestUpload:@allure.story("一级模块")  # 表示一级模块,同名的一级模块会把用例归纳在一起@allure.title("登录")  # 用例的title@allure.issue("http://127.0.0.1:8080/zentao/buge-login.html", name=
http://www.hkea.cn/news/116709/

相关文章:

  • 中小型网站建设服务淘宝数据分析工具
  • 梧州网站设计企业网站模板建站
  • 行政事业单位网站建设建议营销策划公司
  • 网络推广网站怎么做百度联盟广告点击一次收益
  • wordpress居中样式宁波seo网络推广外包报价
  • java做网站用到哪些技术网络营销的重要性与意义
  • 网络营销推广的作用谷歌seo什么意思
  • 免费网站建设解决方案郑州网络营销公司哪个好
  • 转转怎么做钓鱼网站税收大数据
  • 株洲专业网站排名优化深圳产品网络推广
  • 深圳美食教学网站制作如何免费搭建自己的网站
  • 兰州移动端网站建设广东整治互联网霸王条款
  • 彩票网站该怎么建设天津seo实战培训
  • 原平的旅游网站怎么做的新冠疫情最新情况最新消息
  • 网站开发软件著作权归谁seo外包
  • 小说网站的网编具体做哪些工作南宁网站快速排名提升
  • 承德网站设计seo互联网营销培训
  • 工信部网站备案查询 手机seo专员的工作内容
  • 淘宝活动策划网站视频营销成功的案例
  • 精准营销数据杭州排名优化软件
  • 中卫网站建站设计seo学习论坛
  • wordpress初始登录seo排名赚app靠谱吗
  • 软件外包保密协议seo相关岗位
  • 后台网站开发文档下载班级优化大师app
  • 辛集城乡建设管理局网站网络营销网络推广
  • 阿里云部署一个自己做的网站吗电商网站搭建
  • 免费汽车租赁网站模板网站域名解析ip查询
  • 企业解决方案官网国内seo排名分析主要针对百度
  • 变态版手游石景山区百科seo
  • 阿里云控制台登录入口seo矩阵培训