Pycharm+pytest+allure打造测试报告

环境前置提示:
windows7 x64
python3.7
pycharm-professional-2019.3.1
pytest 5.3.2
allure-pytest 2.8.6
allure-commandline-2.13.1
java1.8
1、安装allure
当前最新版本(allure-commandline-2.13.1.zip)下载地址:
https://github.com/allure-framework/allure2/releases/tag/2.13.1
下载解压后,把解压目录放到自定义存放路径,然后在系统变量(参见上面java设置)Path中追加:
~\放置目录\allure-commandline-2.13.1\allure-2.13.1\bin;
点击确定,保存。通过cmd使用allure命令。
在这里插入图片描述
2、安装allure-pytest
pip install allure-pytest

3、一个简单的用例test_simpe.py

import allure
import pytest
@allure.feature('测试用例demo')
class Testcalss:

    @allure.story('测试用例一')
    def test_one(self):
        x='001'
        assert '002' in x

    @allure.story('测试用例二')
    def test_two(self):
        x = '001'
        assert '001' in x

进入文件夹cmd命令:
pytest testcase --alluredir report/allure_raw
在这里插入图片描述
在这里插入图片描述
5、用allure美化报告
allure generate report/allure_raw -o report/allure_report --clean
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

posted @ 2020-05-22 12:20  曹_小_伟  阅读(352)  评论(0)    收藏  举报