2014-10-17 42 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的報告,引起第二個被棄用。