Generating allure report using pytest

Lavanya picture Lavanya · Oct 18, 2014 · Viewed 26.9k times · Source

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.

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

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?

Answer

George Regentov picture George Regentov · Nov 27, 2014

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

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

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

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

  4. 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.

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

  6. 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>

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

*Note <some directory> the same for all steps