pytest-allure相关

安装

  • mac 安装allure
     brew install alluer
    
  • 安装插件 allure-pytest
    pip3 install allure-pytest
    

生成报告

  • 第一种方式
    pytest test_01.py --alluredir=./report --clean-alluredir
    allure serve /Users/xxx/Documents/dev/report
    
  • 第二种方式
    pytest test_01.py --alluredir=./report --clean-alluredir
    allure generate ./report -o ./report/webreport # 第一个路径是生成的数据路径 第二个路径是生成html报告放到什么路径下面
    

allure函数使用

  • 一级标题allure.epic

    @allure.epic("测试登录模块1")
    def test001():
        with allure.step("打开浏览器"):
            pass
    
  • 二级标题allure.feature

    @allure.feature("测试登录模块2")
    def test001():
        with allure.step("打开浏览器"):
            pass
    
  • 三级标题allure.story

    @allure.story("测试登录")
    def test001():
        with allure.step("打开浏览器"):
            pass
    
  • 用例名称allure.title

    @allure.title("测试用例") # 测试报告讲函数名替换成该用例名称
    def test001():
        with allure.step("打开浏览器"):
            pass
    
  • 执行步骤allure.step

    @allure.title("测试用例") # 测试报告讲函数名替换成该用例名称
    def test001():
        with allure.step("打开浏览器"):
            pass
    
posted @ 2022-10-06 16:35  zhq9  阅读(17)  评论(0编辑  收藏  举报