Saturday, 9 September 2017

Python Reporting || allure Reports + pytest

Allure Framework is a flexible lightweight multi-language test report tool gives beautiful reports for any programming language

Sample Code:
Sample.py

def inc(x):
    return x + 1

def test_answer():
    assert inc(3) == 5


Install required pytest, allure adaptor libraries via pip

pip install pytest
pip install pytest-allure-adaptor


First Step:
During test execution, a small library called adapter attached to the testing framework saves information about executed tests to XML files.

> pytest Sample.py -m alluredir G:\Dir1\

- Here xml files will be genarated.

Second Step:
During report generation, the XML files are transformed to a HTML report. This can be done with a command line tool.

Second Step/ Software setup:
download allure from here https://bintray.com/qameta/generic/allure2
unzip, and set Path variable to C:\Users\userName\Downloads\allure-2.3.5\bin;

open command window > allure --version
--o/p: 2.3.5

XML to HTML file conversion
open command window > allure serve G:\Dir1\

Thats all, Automatically allure report will be opened shown like below.








No comments:

Post a Comment