How to Integrate Allure Reports in your test automation

Gaurav Khurana
3 min readJun 11, 2024

--

In this tutorial, we will explore how to generate/integrate Allure reports, a visually appealing and highly configurable reporting tool for your tests.

There are just 3 steps by which you can generate/integrate great looking reports which can be single pager too and easy to integrate with any test framework you are using be it TestNG, Junit, Specflow, Cucumber, pytest or most of it.

Looking for guidance in testing / automation / career — feel free to connect

Here’s a step-by-step guide for Java + TestNG. Approach remains similar for others framework too which you can see on their official site:

Allure Report (allure-framework.github.io) ← checkout how it looks and you will be a fan of this report

Stunning single page interactable HTML Allure Reports | Selenium + Java + TestNG — YouTube

Step 1: Install Allure

1.1 Install Scoop:
— Run the following commands in PowerShell:

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
Invoke-RestMethod -Uri https://get.scoop.sh | Invoke-Expression

1.2 Install allure via scoop and verify Allure Installation:
allure — version

scoop install allure
allure — version

Step 2: Set Up Your Project

  1. Create Configuration File:
    — Under src/test/resources, create an allure.properties file with below contents:
allure.results.directory=target/allure-results

2. Add Dependencies:
— Add the following dependencies to your pom.xml: you can change 2.13.8 to latest version available

<dependency>  
<groupId>io.qameta.allure</groupId>
<artifactId>allure-testng</artifactId>
<version>2.13.8</version>
</dependency>

Step 3: Annotate Your Test Cases

  1. Use Annotations:
    — Enhance your tests with Allure annotations:
    @Description("This test attempts to log into the website using a login and a password. Fails if any error happens.\n\nNote that this test does not test 2-Factor Authentication.")
@Severity(CRITICAL)
@Owner("gaurav khurana")
@Link(name = "Website", url = "https://dev.example.com/")
@Issue("AUTH-123")
@TmsLink("TMS-456")
@Epic("Web interface")
@Feature("Essential features")
@Story("Authentication")
@AllureId("Authentication")
public void OpenInChrome()
{
Allure.suite("Gaurav");
Allure.epic("AuthenticationInsideEpic");

WebDriver driver;
System.out.println("starting chrome browser...");
driver = new ChromeDriver();
driver.get("https://udzial.com");
driver.quit();
System.out.println("chrome browser closed ...");

Allure.attachment("data.txt", "This is the file content.");
try (InputStream is = Files.newInputStream(Paths.get("failed.png"))) {
Allure.attachment("image.png", is);

} catch (IOException e) {
throw new RuntimeException(e);
}

}
  1. Add Attachments:
    — Attach files or screenshots in your tests:
Allure.addAttachment(“Screenshot”, new FileInputStream(“path/to/screenshot.png”));

Step 4: Generate and View Reports

  1. Run Your Tests:
    — Execute your test cases as usual.
  2. Serve the Report:
    — Generate the report using:
allure serve target/allure-results

Step 5: Generate a Single HTML File

  1. Create Single File Report:
    — Use the following command to generate a single HTML report:
allure generate target/allure-results -o target/allure-report — clean  
allure report open -o target/allure-report — single-file

Looking for guidance in testing / automation / career — feel free to connect

Conclusion

Allure reports provide a powerful way to visualize and analyze your test results. By following these steps, you can easily integrate Allure into your project and generate comprehensive reports that highlight the performance and results of your tests.
For more detailed documentation, visit the Allure official site. Happy testing!

lets connect bit.ly/khuranagaurav and do like / comment if you like the post,
In case you are stuck, i would try my best to help you, leave the comment below

--

--