自动化移动测试第10篇:Allure,pytest中使用allure

39 阅读1分钟

🚀🚀🚀本篇主要内容

Allure

学习目标

* 掌握allure的安装和基本使用

1. Allure介绍

Allure是一款非常轻量级并且非常灵活的开源测试报告生成框架, 能够生成美观易读的报告,目前支持语言:Java, PHP, Ruby, Python, Scala, C#。它支持绝大多数测试框架, 例如TestNG、Pytest、JUint等。它简单易用,易于集成.

2. Pytest框架集成Allure

Pytest是Python的单元测试框架,非常方便和易用, 已经使用过了,接下来主要介绍如何将测试报告生成工具Allure集成到Pytest中。

2.1 安装Allure Pytes

pytest中使用allure

学习目标

* 能够在测试脚本中添加测试步骤和设置错误级别

1、添加测试步骤

添加测试步骤的目的: 便于在测试报告中明确的显示是第几步发生了错误

方法:

@allure.step(title="测试步骤001")

示例代码

test_allure_report.py

import allure
import pytest

class TestAllure:

    def setup(self):
        print('---> setup')

    def teardown(self):
        print('teardown')

      @pyte