Allure reporting helps you see clear and beautiful test results. It makes understanding test outcomes easy and fast.
0
0
Allure reporting integration in Selenium Java
Introduction
You want to share test results with your team in a simple way.
You need to track which tests passed or failed over time.
You want screenshots or logs attached to test reports automatically.
You want to organize test results by features or test cases.
You want to generate reports after running Selenium tests.
Syntax
Selenium Java
1. Add Allure dependencies in your Maven pom.xml: <dependency> <groupId>io.qameta.allure</groupId> <artifactId>allure-junit5</artifactId> <version>2.21.0</version> <scope>test</scope> </dependency> 2. Annotate your test class or methods: import io.qameta.allure.Description; import io.qameta.allure.Step; import org.junit.jupiter.api.Test; @Description("Test description here") public class MyTest { @Step("Open homepage") public void openHome() { // test steps } @Test public void testExample() { openHome(); // assertions } } 3. Run tests with Maven and generate report: mvn clean test allure serve target/allure-results
Use @Step to mark important actions in your test for better report details.
Allure collects results in target/allure-results folder by default.
Examples
This example shows how to add a step with a dynamic name using parameters.
Selenium Java
import io.qameta.allure.Step; @Step("Login with username {username}") public void login(String username) { // login code }
This test has a description that appears in the Allure report.
Selenium Java
import io.qameta.allure.Description; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Assertions; @Description("Verify homepage title") @Test public void testHomeTitle() { String title = driver.getTitle(); Assertions.assertEquals("Home", title); }
Sample Program
This test opens a browser, goes to example.com, checks the page title, and closes the browser. All steps and description will appear in the Allure report.
Selenium Java
import io.qameta.allure.Description; import io.qameta.allure.Step; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver; public class AllureSeleniumTest { WebDriver driver; @Step("Open browser and navigate to example.com") public void openBrowser() { driver = new ChromeDriver(); driver.get("https://example.com"); } @Step("Check page title") public void checkTitle() { String title = driver.getTitle(); Assertions.assertEquals("Example Domain", title); } @Description("Test to open example.com and verify title") @Test public void testExampleDotComTitle() { openBrowser(); checkTitle(); driver.quit(); } }
OutputSuccess
Important Notes
Make sure to install Allure command line tool to generate and view reports.
Use meaningful step names to make reports easy to understand.
Attach screenshots or logs in steps for better debugging.
Summary
Allure reporting makes test results clear and easy to share.
Use annotations like @Step and @Description to add details.
Run tests and generate reports with Maven and Allure commands.