0
0
Selenium Javatesting~20 mins

Allure reporting integration in Selenium Java - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Allure Reporting Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
Allure Step Annotation Output
What will be the output in the Allure report when the following Java method annotated with @Step is executed during a Selenium test?
Selenium Java
import io.qameta.allure.Step;

public class LoginTest {
    @Step("Enter username {username}")
    public void enterUsername(String username) {
        System.out.println("Typing username: " + username);
    }

    public void testLogin() {
        enterUsername("user123");
    }
}
AThe Allure report shows a step named 'Enter username {username}' literally without replacing the parameter.
BThe Allure report shows a step named 'enterUsername' without parameters and no console output.
CThe Allure report shows no steps because @Step annotation is ignored at runtime.
DThe Allure report shows a step named 'Enter username user123' with the console output 'Typing username: user123'.
Attempts:
2 left
💡 Hint
The @Step annotation supports parameter placeholders in curly braces that get replaced with actual values.
assertion
intermediate
2:00remaining
Allure Attachment Assertion
Which assertion correctly verifies that an image attachment was added to the Allure report in a Selenium Java test?
Selenium Java
import io.qameta.allure.Allure;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;

public class ScreenshotTest {
    @Test
    public void testScreenshotAttachment() {
        byte[] image = new byte[]{1, 2, 3};
        Allure.addAttachment("Screenshot", "image/png", new java.io.ByteArrayInputStream(image), ".png");
        // Which assertion below confirms the attachment was added?
    }
}
AassertTrue(Allure.getLifecycle().getCurrentTestCase().isPresent()); // Checks current test case exists
BNo direct assertion is possible; attachments are verified by reviewing the Allure report output.
CassertNotNull(image); // Checks the image byte array is not null
DassertEquals("Screenshot", Allure.getLifecycle().getCurrentTestCase().get().getName());
Attempts:
2 left
💡 Hint
Allure attachments are stored in report files, not accessible via direct assertions in code.
🔧 Debug
advanced
2:00remaining
Allure Report Missing Steps Debugging
A Selenium Java test uses @Step annotations, but the Allure report shows no steps recorded. What is the most likely cause?
AThe Allure listener is not registered or the test runner is not configured to generate Allure results.
BThe @Step annotation is used on static methods, which Allure does not support.
CThe test methods are private, so @Step annotations are ignored.
DThe Allure dependency is missing from the Maven or Gradle build file.
Attempts:
2 left
💡 Hint
Allure needs a listener or plugin to capture test execution events and generate results.
framework
advanced
2:00remaining
Integrating Allure with Selenium and TestNG
Which code snippet correctly integrates Allure reporting with Selenium tests using TestNG?
Selenium Java
import io.qameta.allure.Step;
import org.testng.annotations.Test;

public class SearchTest {

    @Step("Open Google homepage")
    public void openHomePage() {
        // Selenium code to open page
    }

    @Test
    public void testSearch() {
        openHomePage();
        // Additional test steps
    }
}
AAdd @ExtendWith(AllureExtension.class) annotation to the test class.
BAdd @RunWith(AllureRunner.class) annotation to the test class.
CAdd @Listeners({io.qameta.allure.testng.AllureTestNg.class}) annotation to the test class.
DNo additional configuration is needed; Allure works automatically with TestNG.
Attempts:
2 left
💡 Hint
TestNG requires listeners to integrate with Allure reporting.
🧠 Conceptual
expert
2:00remaining
Best Practice for Attaching Screenshots in Allure Reports
In a Selenium Java test, what is the best practice to attach a screenshot to the Allure report only when a test fails?
AUse a TestNG @AfterMethod annotated method to check test result and attach screenshot only on failure.
BCall Allure.addAttachment() unconditionally in every test method after taking a screenshot.
CAttach screenshots manually by opening the Allure report and adding images after test execution.
DUse @Step annotation on the screenshot method so it attaches automatically regardless of test result.
Attempts:
2 left
💡 Hint
Test frameworks provide hooks to run code after each test with access to test status.