【allure】测试报告

  • Allure介绍

    • Allure是一款测试报告框架,不仅报告美观,而且方便CI集成。
    • allure是一款开源的,专门用来展示测试结果的一个工具,allure可以与很多的测试框架做集成,比如:java的Junit、TestNG;python的pytest等。
    • allure会将测试用例的执行数据保存到xml或者json文件中去,再利用allure的命令行将文件转换成HTML形式呈现出来。
  • Allure环境搭建

  • Allure使用

    • 1、allure用例描述
#代码示例:
import pytest,time
import allure

@allure.feature('demo模块')
@allure.story('登录功能')
class Test_class:
    @allure.title('正常登录')
    @allure.severity('P1级用例')
    @allure.testcase('https://www.cnblogs.com/hls-code/p/15166015.html')
    def test_001(self):
        a = 'hello'
        b = 'hello world'
        time.sleep(1)
        assert a != b
        print('测试用例--001')

    @allure.title('异常登录')
    @allure.description('密码错误')
    @allure.testcase('http://t.zoukankan.com/liudinglong-p-13056109.html')
    def test_002(self):
        a = 1
        b = 2
        assert a+b == 3
        time.sleep(1)
        print('测试用例--002')

@allure.feature('demo模块')
@allure.testcase('https://www.baodu.com')
@allure.issue('bug链接')
@pytest.mark.xfail
def test_003():
    a = 'hello'
    b = 'hello world'
    time.sleep(1)
    assert a in b
    print('测试用例--003')
  • 2、生成报告:pytest --alluredir ./report/allure_raw

    • 指定测试报告存放路径 ./report/allure_raw ,当前目录下report文件下的report/allure_raw
    • 注意:这里是生成报告的原始文件,无法使用浏览器直接打开
  • 3、运行报告:

    • 3.1:allure serve report/allure_raw
      • 查看报告:
posted @ 2022-08-14 18:08  Tony_xiao  阅读(489)  评论(0编辑  收藏  举报