使用 pytest 生成诱惑报告 [英] Generating allure report using pytest

查看:42
本文介绍了使用 pytest 生成诱惑报告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am using py test allure adaptor and trying to generate input data required for allure report. But I am not able to generate any XML's. When I execute the py file using py.test sample.py, it did create pycache dir. Then I executed "allure generate -v 1.3.9 C:\allurereports" (This is the dir where I had the sample.py). It did create an allure html report but no of test cases was 0. No details were present.

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

The sample.py(it is same as given in the example)

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 sample.py --allure_features=feature1,feature2

Here's the py.test command used: py.test sample.py --allure_features=feature1,feature2

有人能帮我如何从文件中生成诱惑报告吗?要执行的命令是什么?

Can anybody help me how to generate an allure report from the file? What are the commands to execute?

推荐答案

Lavanya.我将尝试解释您必须执行以生成自动测试吸引力报告的顺序.

Lavanya. I'll try to explain the sequence you must to perform to generate allure report of autotest.

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

  1. Install pip. Download get-pip.py and perform python get-pip.py.

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

Install pytest and pytest-allure-adaptor via pip. Perform python -m pip install pytest pytest-allure-adaptor

生成自动测试诱惑 xml 报告.执行 python -m pytest sample.py --alluredir <某个目录>

Generate autotest allure xml report. Perform python -m pytest sample.py --alluredir <some directory>

在<某个目录>中出现 xml 自动测试报告,其中包含 sample.py 测试的结果.让我们通过 allure-cli 工具制作 Beauty html 报告.

In <some directory> appear xml autotest report, which contain results of sample.py tests. Let's make beauty html report via an allure-cli tool.

安装 allure-cli.下载 最新版本的 allure-cli.allure-cli 需要 java.allure-cli 不需要安装,解压使用即可.

Install allure-cli. Download last version of allure-cli. allure-cli requires java. allure-cli doesn't require installation, just unpack and use it.

生成 html 报告.在解压后的 zip 中找到 allure(Windows 的 allure.bat).执行 allure.bat generate -o <某个目录>-v 1.4.0 <某个目录>

Generate html report. Find allure (allure.bat for Windows) in unpacked zip. Perform allure.bat generate -o <some directory> -v 1.4.0 <some directory>

在<某个目录>中找到index.html;并通过浏览器打开它.

Find index.html in <some directory> and open it via a browser.

*注意 <某个目录>所有步骤都一样

*Note <some directory> the same for all steps

这篇关于使用 pytest 生成诱惑报告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆