相信初次使用python+pytest+allure生成html图像化测试报告的小白们都多多少少入了不少坑,走了不少弯路,我同样是一枚小白,记录一下成功生成了html图形化报告的具体操作步骤,仅供参考。
我是使用的openpyxl进行的测试用例读取,那首先我们需要安装相对应的库
1、安装openpyxl
pip install openpyxl
2、安装pytest
pip install pytest
3、安装allure
pip install pytest-allure
#pip install pytest-allure-adaptor
#pip install pytest-allure-adaptor2
看到好多朋友提到pytest-allure-adaptor,不知道是否是因为我安装的是python3的缘故,当时使用pytest-allure-adaptor2总是报错,pytest-allure对我来说是足够用的
4、下面是一个使用openpyxl读取excel的方法
import openpyxl
# file:excel文件名称;sheet_name:excel中sheet表的名称
def read_excel(file,sheet_name):
workbook = openpyxl.load_workbook(file)
sheet = workbook[sheet_name]
# 读取行数据
rows = list(sheet.rows)
data_list