一、前言
之前写了个pytest的allure相关的教程,只是停留在环境搭建完成,后续一直没用,小编一直不喜欢这种花里胡哨的报告
没办法,领导就喜欢这种,小伙伴们也喜欢,所以还是得把allure用起来,给领导一个漂亮的报告,也好加鸡腿
二、allure-pytest 环境准备
windows环境相关:
1.python 3.6版本
2.pytest 3.6.3版本
3.allure-pytest 2.8.6 最新版
使用pip安装pytest和allure-pytest,加上—index-url地址,下载会快一些
pip install pytest==3.6.3 —index-url https://pypi.douban.com/simple
pip install allure-pytest==2.8.6 —index-url https://pypi.douban.com/simple
安装完成之后,打开一个你之前写的pytest脚本,看能不正常使用,如果报错:AttributeError: module ‘allure’ has no attribute ‘severity_level’
这个是之前 pytest-allure-adaptor 这个插件与 allure-pytest 不能共存,卸载掉 pytest-allure-adaptor
pip uninstall pytest-allure-adaptor
三、allure命令行工具
allure是一个命令行工具,需要去github上下载最新版:https://github.com/allure-framework/allure2/releases
下载完成之后,解压到本地电脑
把bin目录添加到环境变量Path下
四、用例demo
conftest.py内容
import pytest
@pytest.fixture(scope="session")
def login():
print("用例先登录")
test_allure_demo.py内容