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

建设部网站安全事故百度产品

建设部网站安全事故,百度产品,在线做效果图的网站有哪些,重庆有哪些做网站的公司文章目录 一、企业级的Allure报告的定制左边的定制:右边的定制:1.用例的严重程度/优先级2.用例描述3.测试用例连接的定制4.测试用例步骤的定制5.附件的定制 二、企业中真实的定制有哪些?三、allure报告如何在本地访问四、allure中的数据驱动装…

文章目录

      • 一、企业级的Allure报告的定制
        • 左边的定制:
        • 右边的定制:
          • 1.用例的严重程度/优先级
          • 2.用例描述
          • 3.测试用例连接的定制
          • 4.测试用例步骤的定制
          • 5.附件的定制
      • 二、企业中真实的定制有哪些?
      • 三、allure报告如何在本地访问
      • 四、allure中的数据驱动装饰器
        • 第一种用法
        • 第二种用法
        • 第三种用法
          • YAML的数据文件:
          • YAML数据驱动实现:

一、企业级的Allure报告的定制

左边的定制:

1.史诗(项目名称):@allure.epic(“项目名称:接口自动化测试”)
2.特性(模块名称):@allure.feature(“模块名称:用户模块”)
3.分组(接口名称):@allure.story(“接口名称:查询用户”)
4.测试用例标题:

  • @allure.title(“测试用例标题:输入正确的条件匹配成功”),适用于一个方法对
    应一个用例。
  • allure.dynamic.title(“测试用例标题:输入正确的条件匹配成功”),适用于一个
    方法对应多个用例。也就是有数据驱动的情况。
import allure
import pytest@allure.epic("项目名称:接口自动化测试")
@allure.feature("模块名称:用户模块")
class User:@allure.story("接口名称:查询用户")@allure.title("测试用例标题:输入正确的条件匹配成功")def test_user(self):# allure.dynamic.title("测试用例标题:输入正确的条件匹配成功")print("test_user" )assert 'abc' in 'abcd'
右边的定制:
1.用例的严重程度/优先级
  • blocker:中断缺陷&致命bug:内存泄漏,用户数据丢失,系统奔溃。
  • critical:临界缺陷&严重bug:功能未实现,功能错误,重复提交
  • normal:一般缺陷&一般bug,条件查询有误,大数据了无响应等
  • minor:次要缺陷:提示bug,颜色搭配不好,字体排列不整齐,错别字。
  • trivial:轻微缺陷:轻微bug,没有使用专业术语,必填项无提示,建议。

@allure.severity(allure.severity_level.BLOCKER)
注意:这个装饰器可以修饰方法也可以修饰类。

2.用例描述

和用例标题一样,有两种写法:@allure.description("") allure.dynamic.description("")

import allure
import pytestclass TestUser:@allure.description("用户测试用例描述")@pytest.mark.userdef test_get_userinfo(self):# allure.dynamic.description("用户测试用例描述2")print("get_userinfo" )assert 'abc' in 'abcd'
3.测试用例连接的定制
  • 接口地址:
  • Bug地址:
  • 测试用例的地址:
import allure
import pytestclass TestUser:@allure.link(name="接口地址", url="https://api.weixin.qq.com/cgi‐bin/token")@allure.issue(name="Bug连接", url="https://www.zentao.net/")@allure.testcase(name="测试用例地址", url="https://www.zentao.net/")def test_get_userinfo(self):print("get_userinfo" )assert 'abc' in 'abcd'
4.测试用例步骤的定制

有两种写法:

  • @allure.step("") :不建议使用,不灵活,只能传入一个title值,不能写多个步骤
  • with allure.step(""):推荐使用,比较灵活
import allure
import pytestclass TestUser:# @allure.step("测试步骤")  不建议使用,不灵活,只能传入一个title值,不能写多个步骤@pytest.mark.userdef test_get_userinfo(self):# 增加测试步骤-建议使用for a in range(1, 5):with allure.step("测试用例步骤" + str(a) + ""):print("步骤" + str(a) + "执行的脚本")print("get_userinfo" )assert 'abc' in 'abcd'
5.附件的定制

body=附件内容, name=None文件名, attachment_type=None文件扩展名

  • web自动化
# web自动化
with open(r"./screenshots/logo.png", mode="rb") as f:allure.attach(body=f.read(), name="用户测试错误截图",attachment_type=allure.attachment_type.PNG)
  • 接口自动化
#接口自动化
allure.attach(body="https://api.weixin.qq.com/cgi‐bin/token", name="请求地址:",attachment_type=allure.attachment_type.TEXT)allure.attach(body="get", name="请求方式:", attachment_type=allure.attachment_type.TEXT)data = {"grant_type": "client_credential","appid": "wx6b11b3efd1cdc290","secret": "106a9c6157c4db5f6029918738f9529d"}allure.attach(body=json.dumps(data), name="请求数据:", attachment_type=allure.attachment_type.TEXT)rep = requests.get(url="https://api.weixin.qq.com/cgi‐bin/token", params=data)allure.attach(body=str(rep.status_code)+rep.text, name="响应数据:", attachment_type=allure.attachment_type.TEXT)

二、企业中真实的定制有哪些?

  • 1.@allure.epic(“项目名称”)
  • 2.@allure.feature(“模块名称”)
  • 3.@allure.story(“接口名称”)
  • 4.@allure.severity(allure.severity_level.BLOCKER) 严重程度
  • 5.allure.dynamic.title(“用例名称:测试用例名称”)
  • 6.allure.dynamic.description(“用例描述:测试用例描述”)
  • 7.with allure.step(“测试步骤的名称”)
  • 8.allure.attach(body, name, attachment_type, extension) 测试用例附件

7与8一般会进行封装,后期讲解

三、allure报告如何在本地访问

因为pycharm自带容器:tomcat,Nginx,weblogic。有以下两种方式实现本地访问

  • 1.在本地搭建本地服务器。
  • 2.通过启动服务打开allure报告。(简单)
    allure open [报告路径]

四、allure中的数据驱动装饰器

@pytest.mark.parametrize(参数名,数据(list,tuple,字典列表,字典元祖))

第一种用法
@allure.story("接口名称:测试数据驱动")
@pytest.mark.parametrize("args_name",["无忧渡","藏海传","折腰"])
@pytest.mark.user
def test_get_data(self,args_name):print(args_name)
第二种用法
@allure.story("接口名称:测试数据驱动")
@pytest.mark.parametrize("order,name",[["01","《无忧渡》"],["04","《藏海传》"],["03","《折腰》"]])
@pytest.mark.user
def test_get_data(self,order,name):print("序号:"+order+"剧名:"+name)
第三种用法

使用yaml 数据进行数据驱动
YAML有两种数据:

  • -开头的代码list
  • 键值对:key:value
YAML的数据文件:
 -name: get correct user tokendescription: When trying to obtain a user token with a valid appid, correct secret, and correct grant_type, the request will succeed.request:url: https://api.weixin.qq.com/cgi-bin/tokenmethod: GETdata:appid: wx74a8627810cfa308secret: e40a02f9d79a8097df497e6aaf93ab80grant_type: client_credentialvalidate: None-name: don't get correct user tokendescription: When trying to obtain a user token with an empty appid, correct secret, and correct grant_type, an error occurs.request:url: https://api.weixin.qq.com/cgi-bin/tokenmethod: GETdata:appid:secret: e40a02f9d79a8097df497e6aaf93ab80grant_type: client_credentialvalidate: None-name: don't get correct user tokendescription: When trying to obtain a user token with an correct appid, error secret, and correct grant_type, an error occurs.request:url: https://api.weixin.qq.com/cgi-bin/tokenmethod: GETdata:appid: wx74a8627810cfa308secret: e40a02f9d79a8097df497e6aaf93ab81grant_type: client_credentialvalidate: None-name: don't get correct user tokendescription: When trying to obtain a user token with an correct appid, correct secret, and empty grant_type, an error occurs.request:url: https://api.weixin.qq.com/cgi-bin/tokenmethod: GETdata:appid: wx74a8627810cfa308secret: e40a02f9d79a8097df497e6aaf93ab81grant_type:validate: None
YAML数据驱动实现:

注:记得安装 PyYAML

# -*- coding: utf-8 -*-
import json
import allure
import pytest
import requests
import yaml# 读取 yaml 文件
def read_yaml(path):with open(path,mode="r",encoding="utf-8") as f:value = yaml.load(f,Loader=yaml.FullLoader)return value@allure.epic("项目名称:接口自动化测试")
@allure.feature("模块名称:用户模块")
class TestUser:@allure.story("接口名称:获取用户token")@allure.severity(allure.severity_level.BLOCKER)@pytest.mark.user@pytest.mark.parametrize("case_info",read_yaml("./testcases/user_manage/get_token.yml"))def test_get_user_token(self,case_info):print(case_info)allure.dynamic.title(case_info['name'])allure.dynamic.description(case_info['description'])allure.attach(body=case_info['request']['url'],name="请求地址:",attachment_type=allure.attachment_type.TEXT)allure.attach(body=case_info['request']["method"],name="请求方式:",attachment_type=allure.attachment_type.TEXT)data = case_info['request']["data"]allure.attach(body=json.dumps(data),name="请求数据:",attachment_type=allure.attachment_type.TEXT)rep = requests.get(url=case_info['request']['url'],params=data)allure.attach(body=str(rep.status_code) + rep.text,name="响应数据:",attachment_type=allure.attachment_type.TEXT)
http://www.dtcms.com/wzjs/308681.html

相关文章:

  • 做网站台式还是笔记本小吃培训
  • 麻将app软件开发价格seo技巧seo排名优化
  • wordpress 设置显示中文字体长沙网站seo公司
  • 棋牌网站制作价格seo自媒体培训
  • 做网站吧网页模板下载
  • 白市驿网站建设网站建站在线制作
  • wap手机网站开发软件手机网站seo免费软件
  • 做 个收废品网站seo优化论坛
  • 塑胶模具东莞网站建设在哪买网站链接
  • 建设网站 证件网站优化的意义
  • 建设厅网站174号文如何让别人在百度上搜到自己公司
  • 在线建站网站软件开发公司推荐
  • 在线做六级阅读网站win11优化大师
  • 建设的访问网站需要密码如何建立一个自己的网站
  • 营销网站建设联系方式指数基金投资指南
  • 帮客户做网站平台犯法吗什么是seo
  • 湛江市建设局官方网站免费网站在线客服软件
  • 合肥网站建站工作室百度小说风云榜排行榜官网
  • 国产av毛片亚洲含羞草社福州seo推广服务
  • 视频网站亏损也做中国搜索
  • 郑州网站推广服务小红书关键词优化
  • 建设学校网站的操作流程具体关键词网站查询
  • 公司网站修改怎么做三明网站seo
  • 淘宝客做网站链接关键词推广是什么
  • wordpress收费会员插件百度seo优
  • 南京网站建设哪家专业网站seo搜索引擎优化怎么做
  • 怎样把域名和做的网站连接不上排名优化方法
  • 做网站网页维护手机App开发如何写好软文推广
  • 做标书经验分享网站百度主页
  • 网站设计标准尺寸网络推广学校