python - 使用pytest生成 Allure 报告

标签 python pytest allure

我正在使用 py test allure adapter 并尝试生成 allure 报告所需的输入数据。但我无法生成任何 XML。当我使用 py.test sample.py 执行 py 文件时,它确实创建了 pycache 目录。然后我执行了“allure generate -v 1.3.9 C:\allurereports”(这是我有 sample.py 的目录)。它确实创建了一个 allure html 报告,但没有测试用例为 0。没有详细信息。

sample.py(与示例中给出的相同)

import allure


@allure.feature('Feature1')
@allure.story('Story1')
def test_minor():
    assert False


@allure.feature('Feature2')
@allure.story('Story2', 'Story3')
@allure.story('Story4')
class TestBar:

    # will have 'Feature2 and Story2 and Story3 and Story4'
    def test_bar(self):
        pass

这是使用的 py.test 命令: py.test 示例.py --allure_features=feature1,feature2

任何人都可以帮助我如何从文件生成 Allure 报告吗?要执行的命令是什么?

最佳答案

拉瓦尼亚。 我将尝试解释生成自动测试的诱惑报告所必须执行的顺序。

  1. 安装pip。下载 get-pip.py 并执行 python get-pip.py

  2. 通过 pip 安装 pytestpytest-allure-adaptor。执行 python -m pip install pytest allure-pytest

  3. 生成自动测试 allure xml 报告。执行 python -m pytest sample.py --alluredir

  4. 中出现xml 自动测试报告,其中包含sample.py 测试的结果。让我们通过 allure-cli 工具制作美容 html 报告。

  5. 安装 allure-cli。下载 last version of allure-cli . allure-cli 需要 java。 allure-cli 不需要安装,just unpack and use it .

  6. 生成 html 报告。在解压缩的 zip 中找到 allure(Windows 的 allure.bat)。执行allure.bat generate -o -v 1.4.0

  7. 中找到index.html并通过浏览器打开。

*注意 所有步骤都一样

关于python - 使用pytest生成 Allure 报告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26434791/

相关文章:

python - 从多对多字段中获取对象

Python SQLITE3 插入 : if exist than make addition

python - 在 matplotlib 中为颜色条添加白色背景

django - Fixtures 不应该被直接调用

java - Selenide:Allure 报告中缺少 @Step 注释

python - randomkit.h 发生了什么或如何迁移到最新的 numpy.random c/cython api

python-3.x - 如何将 Pytest 的日志附加到 Allure Report 中

python - 使用 Flask 进行 pytest 无法找到模块

java - 当 b 很大时 Allure @Step(String s, byte[] b) (2.12.1 allure)

java - 如何使用 Allure 组织 junit 测试套件