2014-10-17 97 views
5

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

的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 sample.py --allure_features =特征1,特征

任何人都可以帮助我如何从文件生成一个魅力报告。什么是要执行的命令。

回答

12

Lavanya。 我会尝试解释你必须执行的顺序来生成自动测试的诱惑报告。

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

  2. 安装pytest,并通过PIP pytest-诱惑适配器。执行python -m pip install pytest pytest-allure-adapter

  3. 生成autotest属性xml报告。执行蟒蛇-m pytest sample.py --alluredir <一些目录>

  4. 在<一些目录>出现XML自动测试报告,其中包含的sample.py测试的结果。让我们通过allure-cli工具制作美丽的html报告。

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

  6. 生成html报告。在unpacked zip中查找allure(适用于Windows的allure.bat)。执行allure.bat生成-o <某些目录> -v 1.4。在一些目录>

  7. 查找index.html的一些目录>,并通过浏览器打开它。

*注意 <一些目录>都是一样的步骤

+2

我在安装pytest-allure-adaptor包时遇到了一些问题。它取决于'lxml',最后一个会自动安装。请参阅[Requires Distributions](https://pypi.python.org/pypi/pytest-allure-adaptor)以获取依赖关系。即,'lxml'安装会导致问题。根据[this],将'libxml2-dev'和'libxslt1-dev'软件包安装到我的系统中(http://stackoverflow.com/questions/13019942/why-cant-i-get-pip-install-lxml- to-work-within-a-virtualenv)和[this](http://stackoverflow.com/questions/5178416/pip-install-lxml-error),解决了这个问题。 – Andriy 2016-01-13 16:01:29

0

现在你必须使用诱惑的命令行,而不是诱惑,CLI生成HTML的报告,引起第二个被弃用。