美文网首页
学习笔记-Pytest+Allure环境搭建

学习笔记-Pytest+Allure环境搭建

作者: sofiiii | 来源:发表于2019-02-11 16:15 被阅读0次

1. allure简介


Allure是一款非常轻量级并且非常灵活的开源测试报告生成框架。 它支持绝大多数测试框架, 例如TestNG、Pytest、JUint等。它简单易用,易于集成。下面就Pytest如何与Allure集成做详细介绍。

2. 配置环境


  • 安装pytest
pip3 install pytest
pip3 install allure-pytest
allure --version

3. 新建demo


import allure
import pytest


@allure.feature('测试用例1')
def test_case_01():
    """
    用例描述:Test case 01
    """
    assert 0


@allure.feature('测试用例2')
def test_case_02():
    """
    用例描述:Test case 02
    """
    assert 0 == 0


if __name__ == '__main__':
    pytest.main(['-s', '-q', '--alluredir', './report/xml'])

4. 生成测试报告


pytest xxx.py --alluredir [xml_path]
allure generate [xml_path] -o [report_path]

相关文章

网友评论

      本文标题:学习笔记-Pytest+Allure环境搭建

      本文链接:https://www.haomeiwen.com/subject/mylysqtx.html