我正在使用 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 报告吗?要执行的命令是什么?
最佳答案
拉瓦尼亚。 我将尝试解释生成自动测试的诱惑报告所必须执行的顺序。
安装pip。下载 get-pip.py 并执行 python get-pip.py。
通过 pip 安装 pytest 和 pytest-allure-adaptor。执行 python -m pip install pytest allure-pytest
生成自动测试 allure xml 报告。执行 python -m pytest sample.py --alluredir
在
中出现xml 自动测试报告,其中包含sample.py 测试的结果。让我们通过 allure-cli 工具制作美容 html 报告。 安装 allure-cli。下载 last version of allure-cli . allure-cli 需要 java。 allure-cli 不需要安装,just unpack and use it .
生成 html 报告。在解压缩的 zip 中找到 allure(Windows 的 allure.bat)。执行allure.bat generate -o
-v 1.4.0 在
中找到index.html并通过浏览器打开。
*注意
关于python - 使用pytest生成 Allure 报告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26434791/