Creating Custom Reports Using Allure
Allure is a powerful and flexible reporting framework often used in test automation frameworks with Selenium, TestNG, JUnit, and other tools. While Allure automatically generates rich test reports, you can customize these reports to suit your project’s needs by adding labels, descriptions, steps, attachments, and categories.
Here’s a step-by-step guide to creating custom reports using Allure:
🔹Set Up Allure in Your Project
If you’re using Maven, add Allure dependencies and plugins:
<dependencies>
<dependency>
<groupId>io.qameta.allure</groupId>
<artifactId>allure-testng</artifactId> <!-- or allure-junit5 -->
<version>2.24.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>io.qameta.allure</groupId>
<artifactId>allure-maven</artifactId>
<version>2.11.2</version>
</plugin>
</plugins>
</build>
🔹 Use Annotations for Customization
Allure provides several annotations to customize your test reports:
import io.qameta.allure.*;
@Epic("Login Module")
@Feature("User Login")
@Story("Valid Login")
@Owner("QA Tester")
@Severity(SeverityLevel.CRITICAL)
@Description("This test verifies valid login for existing user.")
@Test
public void validLoginTest() {
Allure.step("Open login page");
Allure.step("Enter username and password");
Allure.step("Click login button");
Allure.step("Verify home page is displayed");
}
✅ These annotations improve organization and filtering in the Allure report.
🔹 Add Attachments to Report
You can attach logs, screenshots, or files:
@AllureAttachment(value = "Screenshot", type = "image/png")
public byte[] attachScreenshot() {
return ((TakesScreenshot) driver).getScreenshotAs(OutputType.BYTES);
}
Or attach plain text:
@AllureAttachment(value = "Error Logs", type = "text/plain")
public String attachLogs(String message) {
return message;
}
🔹 Customize Categories for Defect Grouping
Create a categories.json file in src/test/resources/allure-results/:
[
{
"name": "UI Failures",
"matchedStatuses": ["failed"],
"messageRegex": ".*element not found.*"
},
{
"name": "Assertion Errors",
"matchedStatuses": ["failed"],
"messageRegex": ".*expected.*but found.*"
}
]
This groups test failures under custom categories in your report.
🔹 Generate Allure Report
After test execution, run:
allure serve target/allure-results
or
allure generate target/allure-results --clean -o target/allure-report
This will launch the report in your browser with all customizations.
🔹 Custom Logos and Branding (Optional)
To customize branding, you can override CSS and images in the Allure report, but this requires deeper knowledge of Allure’s internal layout and is not officially documented.
✅ Best Practices
- Always annotate tests with @Severity, @Owner, and @Description.
- Attach screenshots or logs for failed steps.
- Organize reports using @Epic, @Feature, and @Story.
- Customize categories to simplify triage.
📝 Conclusion
Custom reports in Allure help communicate test results more effectively. By using annotations, attachments, and categories, you can tailor the report to highlight what matters most to your team—making test results easier to read, track, and act upon.
Learn Testing toolsTraining in Hyderabad
Read More:
UFT/QTP: Functional Testing Simplified
How to Use Git and GitHub in Testing Projects
Postman Collections and Automations Explained
Cross Browser Testing Using BrowserStack
Visit our IHub Talent Training Institute
Comments
Post a Comment