Recently, I was on the lookout for a good open-source reporting tool other than the ReportPortal tool which we already integrated with pytest in the past. As a result, I came across a tool called Allure. When I started integrating allure with pytest, I stumbled upon a couple of errors as there was no straightforward guide to do so. Therefore, I am writing this blog post!!
What is Allure?
Allure framework is a lightweight test reporting tool that shows useful information about test execution in a neat web report form. It can be integrated with popular testing frameworks across languages. To know more about allure you can read through its documentation.
Allure integration with pytest
Creating a test
To illustrate how to integrate Allure with pytest, we will be making use of a simple python test that verifies the Qxf2 website’s title.
""" This script will open the Qxf2 website and verify its title """ from selenium import webdriver site_url = 'https://qxf2.com/' def test_site_title(): "Checks Qxf2's website title" driver = webdriver.Chrome() driver.get(site_url) assert driver.title == 'Qxf2 Services: Outsourced Software QA for startups'
- Install allure-pytest python package with command pip install allure-pytest
- Next, download the latest allure package zip file from the allure-framework GitHub repo
- Unzip the downloaded zip file
- Copy the path till bin
- Add it to the path environment variable
- Open your terminal and run
If you see the allure version printed then your setup is successful!!
Generating Allure report using pytest
- In your project directory, you first need to generate a folder to save the allure reports, you can automatically generate this with a command
This will create a folder named allure-report in your project directory.
- You are now set to run your test with pytest runner by specifying the directory path to save your allure report, for example :
Once test execution completes, all the test results would get stored in allure-report directory.
- You can now view the allure-report in the browser with the command –
allure serve allure-report/
Let me know in the comments if this blog helped you to integrate your tests with Allure!!
I am a software tester with more than 3 years of experience. I started my career in an e-commerce startup called Browntape Technologies. I was looking forward to work with a software testing organization which would help me showcase my testing and technical skills. So I joined Qxf2. I love scripting in Python and using Selenium. I live in Goa and enjoy its beaches. My hobbies include playing cricket, driving and exploring new places.