首页 > 其他分享 >【allure】测试报告

【allure】测试报告

时间:2022-08-14 18:11:07浏览次数:84  
标签:测试报告 -- pytest allure https report com

  • Allure介绍

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

    • pip install pytest==4.5.0 --index-url https://pypi.douban.com/simple
    • pip install allure-pytest==2.8.6 --index-url https://pypi.douban.com/simple
    • allure是一个命令行工具,需要去github上下载最新版https://github.com/allure-framework/allure2/releases
      • allure依赖java的jdk环境--自行处理(百度)
      • 下载完成后,解压
      • 把bin目录添加到环境变量Path下
  • 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
      • 查看报告:

标签:测试报告,--,pytest,allure,https,report,com
From: https://www.cnblogs.com/xwltest/p/16585947.html

相关文章

  • allure生成报告
    一、安装allure1.下载Allure安装包:https://github.com/allure-framework/allure2/releases/2.添加到环境变量3.pip安装包:pipinstallallure-pytest4.配置pytest.ini......