Allure reporting helps you see clear and beautiful test results. It makes understanding test outcomes easy and fast.
Allure reporting integration in 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.
import io.qameta.allure.Step; @Step("Login with username {username}") public void login(String username) { // login code }
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); }
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.
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(); } }
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.
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.
Practice
Solution
Step 1: Understand Allure reporting purpose
Allure reporting is designed to make test results easy to read and share by adding detailed steps and descriptions.Step 2: Compare options with Allure features
Only To generate clear and shareable test reports with detailed steps correctly describes Allure's role in generating clear, detailed reports. Other options describe unrelated features.Final Answer:
To generate clear and shareable test reports with detailed steps -> Option AQuick Check:
Allure reporting = clear, shareable reports [OK]
- Confusing Allure with test execution speed tools
- Thinking Allure replaces Selenium WebDriver
- Assuming Allure writes tests automatically
Solution
Step 1: Identify Allure annotations for steps
The@Stepannotation marks methods as steps in Allure reports, adding detailed descriptions.Step 2: Eliminate unrelated annotations
@Test runs tests, @BeforeMethod runs setup, @Ignore skips tests. Only @Step adds step details.Final Answer:
@Step -> Option AQuick Check:
@Step = detailed step in Allure [OK]
- Confusing @Step with @Test annotation
- Using @BeforeMethod for step descriptions
- Thinking @Ignore adds report details
@Step("Open login page")
public void openLoginPage() {
driver.get("https://example.com/login");
}Solution
Step 1: Understand @Step annotation usage
The @Step annotation with a string parameter sets the step name shown in Allure reports.Step 2: Analyze the method behavior
When openLoginPage() runs, Allure logs the step with the name 'Open login page'. No return value is needed.Final Answer:
The report will show a step named 'Open login page' when this method runs -> Option CQuick Check:
@Step("Open login page") = step shown as 'Open login page' [OK]
- Thinking @Step needs a return value
- Assuming steps are ignored without extra config
- Expecting URL to appear instead of step name
Solution
Step 1: Check Allure integration requirements
Allure requires adding listeners or adapters (like Allure TestNG listener) to capture @Step annotations during test execution.Step 2: Identify common misconfigurations
Without the listener, steps are not recorded. The other options are incorrect because Allure supports Selenium tests, @Step works with TestNG, and @Test is for test methods.Final Answer:
You forgot to add the Allure listener or adapter in your test setup -> Option DQuick Check:
Missing listener = no steps in report [OK]
- Assuming @Step works without listener
- Confusing @Step with @Test annotation
- Believing Allure doesn't support Selenium
Solution
Step 1: Understand Maven and Allure commands
To run tests and generate an Allure report, first run tests withmvn clean test, then generate and serve the report withallure:serve.Step 2: Analyze command order
mvn clean test allure:serve correctly runs clean, then tests, then serves the report. Other options have wrong order or invalid commands.Final Answer:
mvn clean test allure:serve -> Option BQuick Check:
Run tests then serve report = mvn clean test allure:serve [OK]
- Running allure commands before tests
- Mixing command order incorrectly
- Using invalid Allure commands
Ready to prove it?
Pass the test and this pattern moves unknown
