一、升级Powershell(windows7及以上版本默认自带、其实普通的CMD命令行工具够用了)

我是Win7默认带的pw1.0,太古老了升级一下,地址如下,选择与自己windows版本匹配的连接下载:

https://docs.microsoft.com/zh-cn/powershell/scripting/install/installing-windows-powershell?view=powershell-6

安装时报错如下:

解决办法:

1.修改xxx.msu文件名后缀为xxx.cab,并解压在当前目录D:\test\xxx\

2.win+r打开运行:并输入dism /online /add-package /packagepath:"D:\test\xxx"

等待安装完成重启电脑,查看版本号 运行PowerShell并输入:$psversiontable或$host

二、allure环境配置

以下均在PowerShell中执行 

1.修改脚本执行授权,会有风险提示的一堆英文,输入A 回车同意即可

执行命令:set-executionpolicy remotesigned -scope currentuser

2.下载并安装scoop包管理工具(为后续安装各种软件包提供便捷)

执行命令:iex (new-object net.webclient).downloadstring('https://get.scoop.sh')

3.安装allure

执行命令:scoop install allure

三、allure生成报告常用指令

进入test_*.py测试脚本目录下

1.执行用例并生成xml文件:pytest -s -q --alluredir=xml_report   #xml_report为执行结果目录

2.按需生成定离线告页面:allure generate xml_report -o my_html   #xml_report为上边执行的结果目录,my_html为指定的美化后的结果页面目录(未指定 -o 目录时,默认生成allure-report目录)

访问这个报告页面,需要使用 firefox浏览器……其它不支持。或者直接在PycharmIDE 的工程目录下 右键点击结果报告里的 index.html文件,选择:open in brower 打开。

3.如果有安装web服务器,可以执行命令生成在线报告:allure serve xml_report,会创建web临时目录(存在C:\Users\Administrator\AppData\Local\Temp),基本支持所有的浏览器访问(360、chrome、ie什么的)

 四、allure定制报告(以下参考 小喜的博客

1、关键字:feature 主要功能模块-一级模块
2、关键字:story: Features下的子功能-二级模块
3、关键字:severity: 标注测试用例的重要级别
4、关键字:step: 标注测试用例的重要步骤
Issue和TestCase: 标注Issue、Case,可加入URL


Allure中对严重级别的定义(若关键字拼写错误,则默认显示normal级别):
1、 关键字-S级:blocker
2、 关键字-A级:critical
3、 关键字-B级:normal
4、 关键字-C级:minor
5、 关键字-D级:trivial

我 一般使用到1~4级便够用了……分级太多反而麻烦。

# -*- coding: utf-8 -*-
import allure
import pytest
from PIL import * @allure.step('检查UI名:{0}打开了')
def ui_check(tips):
return tips f=open('./sc.png','rb').read()
# with open('./sc.png','rb') as f:
# f.read()
@allure.feature('feature:功能名1')
@allure.story('story:1-子功能UI测试')
@allure.severity('normal')
@allure.issue('http://bug.report')#缺陷链接地址
@allure.testcase('http://testcase.com')#用例链接地址
#@allure.attach('sname',f,allure.attachment_type.PNG)
#这是用例标题-功能1-子功能UI测试
def test_call_check_ui(): """
用例描述:UI检查测试
"""
print('UI检查测试')
assert ui_check('Main')=='Main' @allure.feature('feature:功能名1')
@allure.story('story:1-子功能数据测试')
@allure.severity('critical')
def test_app_data():
'''
用例描述:数据测试
'''
print('数据测试') @allure.feature('feature:功能名1')
@allure.story('story:1-子功能逻辑测试')
@allure.severity('critical')
def test_app_logic():
'''
用例描述:逻辑测试
'''
print('逻辑测试') @allure.feature('feature:功能名2')
@allure.severity('trivial')
#这是用例标题-功能2
def test_app_install():
"""
用例描述:test_app_install 应用安装结果统计
"""
print('安装应用') @allure.feature('feature:功能名3')
@allure.severity('blocker')
def test_app_start():
"""
用例描述:test_app_start 应用启动结果统计
"""
print('启动应用并统计启动时间')
assert 1 == 0 @allure.feature('feature:功能名4')
@allure.severity('normal')
def test_app_uninstall():
'''
用例描述:这是描述这个用例的作用
'''
print('卸载应用结果统计') if __name__ == '__main__':
pytest.main(['-s','-q','--alluredir','./report'])

[Mac环境]

1.Allure下载路径:https://github.com/allure-framework/allure2/releases

下载解压包,添加路径

export PATH=${PATH}:/Users/XXX/Downloads/Compressed/allure-2.12.1/bin

到文件: ~/.bash_profile

最后执行:source ~/.bash_profile 即可生效,输入allure --version 查看当前版本

2.安装依赖插件,使用pip命令即可

pip install pytest allure-pytest pytest-html pytest-ordering

【Mac+Wind7】pytest + allure生成定制报告的更多相关文章

  1. 手把手教你Pytest+Allure2.X定制报告详细教程,给自己的项目量身打造一套测试报告-02(非常详细,非常实用)

    简介 前边一篇文章是分享如何搭建pytest+Allure的环境,从而生成一份精美的.让人耳目一新的测试报告,但是有的小伙伴或者童鞋们可能会问,我能不能按照自己的想法为我的项目测试结果量身打造一份属于 ...

  2. Pytest测试框架(五):pytest + allure生成测试报告

    Allure 是一款轻量级.支持多语言的开源自动化测试报告生成框架,由Java语言开发,可以集成到 Jenkins. pytest 测试框架支持Allure 报告生成. pytest也可以生成juni ...

  3. allure生成的报告打开后显示loading

    allure生成的报告打开后显示loading,怎么办? 1. allure生成报告的命令 1.1.生成测试数据 # 命令格式:pytest 相关参数 指定执行的用例 --alluredir=数据存放 ...

  4. python + pytest + allure生成测试报告

    pytest结合allure生成测试报告 环境搭建 要安装java环境,版本要是jdk1.8的,配置好java环境变量,不然输入allure命令会报错,JAVA_HOME环境,自行配置 安装allur ...

  5. pytest 6 生成html报告

    前言:pytest-HTML是一个插件,pytest用于生成测试结果的HTML报告.兼容Python 2.7,3.6 1.github上源码地址[https://github.com/pytest-d ...

  6. pytest + allure 生成测试报告

    pytest测试样例规则:测试文件以test_开头(以_test结尾也可以)测试类以Test开头,并且不能带有 init 方法测试函数以test_开头断言使用基本的assert即可 ubuntu 安装 ...

  7. Pytest+allure生成测试报告

    1.Allure.zip包的下载地址: https://github.com/allure-framework/allure2 在跳转页面选择一个allure.zip包的版本下载 若以上方法无法下载z ...

  8. pytest allure 生成html测试报告

    前提:需要 java 1.8 以上.python3环境 一.下载pytest pip install pytest 二.下载Allure Pytest Adaptor插件 pip install py ...

  9. pytest+allure生成接口自动化测试报告

    准备环境 1.安装pytest pip install pytest -i http://pypi.douban.com/simple pytest-ordering pytest.main([ &q ...

随机推荐

  1. Linux shell基础(五)sed命令

    一.sed命令 sed是一种强大的流式编辑器 (stream editor for filtering and transforming text),它能够完美的使用正则表达式,逐行处理文本并把结果显 ...

  2. Codeforce 1155D Beautiful Array(DP)

    D. Beautiful Array You are given an array aa consisting of nn integers. Beauty of array is the maxim ...

  3. 如何使用badboy录制一个脚本并成功的导入jmeter中?

    前言: 虽然,很多人已经不适用这种方式进行录制脚本了,因为不好维护.但是,还是有一些朋友在刚开始学习的过程中使用badboy. 可能有人会好奇了,人家五一都出去玩了,你在家学习吗?正巧前一阵有粉丝留言 ...

  4. nginx代理vue项目

    很多项目的前端都使用vue编写的,在项目上线部署的时候,有些项目要求把前端页面和后台服务部署在不同的服务器,这就要求使用nginx代理,本文就来讲讲vue项目怎么使用nginx代理. 项目github ...

  5. Re模块的方法补充

    id_str = input("输入一个身份证号:") import re obj = re.compile(r"^([1-9]\d{16}[0-9x]|[1-9]\d{ ...

  6. js和jq的获取焦点失去焦点写法

  7. 【Spark】帮你搞明白怎么通过SparkSQL整合Hive

    文章目录 一.创建maven工程,导包 二.开发代码 一.创建maven工程,导包 <properties> <scala.version>2.11.8</scala.v ...

  8. 【Hadoop离线基础总结】MapReduce自定义InputFormat和OutputFormat案例

    MapReduce自定义InputFormat和OutputFormat案例 自定义InputFormat 合并小文件 需求 无论hdfs还是mapreduce,存放小文件会占用元数据信息,白白浪费内 ...

  9. 小程序-for循环遍历的使用

    .js文件: Page({ /** * 页面的初始数据 */ data: { datas:[ { title: '提交申请', txt: '选择服务类型,填写基本信息,提交' }, { title: ...

  10. 花店橱窗布置问题(FLOWER)

    目录 问题描述 问题分析 Java代码实现 运行结果 今天老师上完课说所有花都要被放,这个算法还是考虑多了,包含了这个选择,代码就不给了,用dp思想就可以解决了. 问题描述   假设你想以最美观的方式 ...