allure reports for pytest

Allure is an open-source framework designed to create test execution reports that are clear to everyone in the team. Allure is based on standard xUnit results output but adds some supplementary data. Any report is generated in two steps.
Step 1: During test execution (first step), a small library called adapter attached to the testing framework saves information about executed tests to XML files. Adapters are provided for popular Java, PHP, Ruby, Python, Scala and C# test frameworks.
Step 2: During report generation (second step), the XML files are transformed to a HTML report. This can be done with a command line tool, a plugin for CI or a build tool

How to go about it:

Install allure
 cmd > pip install pytest-allure-adaptor
Download 
the latest version as zip archive from bintray.
Unpack the archive to allure-commandline directory.
Navigate to bin directory and copy the directory path and add to environment variable path.
Go to your directory where the tests reside and paste the bat file.
Create 2 directories in the same folder viz. allure-reports and xml-reports
My test looks like this:
class Test_Class():
    def test_py_1(self):        print("This is test 1")
        assert False
    def test_py_2(self):        print("This is test 2")

    def test_py_3(self):        print("This is test 3")

    def test_py_4(self):        print("This is test 4")
 Step 1 in introduction section
  Open cmd pointing to the directory where tests reside and run
   py.test test_runInClass.py --alluredir D:\path....\xml-reports
This will run the test and store xml file in the xml-reports directory
Step 2 in introduction section
 Open cmd in allure-reports directory and run
 allure.bat generate -o E:\path....\allure-reports E:\path....\xml-reports
"index.html" is the file we are looking for.
Note: If allure-reports directory already exists the you would need to clean it using the below command  of manually deleting the files
allure.bat generate --clean -o E:\path....\allure-reports E:\path....\xml-reports

So the fancy report looks like this 
 
 
















For python behave BDD framework reporting click here>>
References: https://github.com/allure-framework/allure1/wiki

Comments

Popular Posts