0
0
Selenium Javatesting~20 mins

Extent Reports setup in Selenium Java - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Extent Reports Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
What is the output of this Extent Reports setup code?
Consider the following Java code snippet that initializes Extent Reports in a Selenium test. What will be the output in the generated report after running this code?
Selenium Java
ExtentReports extent = new ExtentReports();
ExtentTest test = extent.createTest("Login Test");
test.pass("Login successful");
extent.flush();
ANo report generated because ExtentReports object was not configured with a reporter.
BA report with no tests because extent.flush() was called before creating the test.
CA report with one test named 'Login Test' marked as failed with message 'Login successful'.
DA report with one test named 'Login Test' marked as passed with message 'Login successful'.
Attempts:
2 left
💡 Hint
ExtentReports requires a reporter (like ExtentHtmlReporter) to be attached via attachReporter() before flush() generates a file.
assertion
intermediate
2:00remaining
Which assertion correctly verifies the test status in Extent Reports?
You want to verify in your Selenium test that the ExtentTest status is marked as FAIL after a failed login attempt. Which assertion is correct?
Selenium Java
ExtentTest test = extent.createTest("Login Test");
test.fail("Login failed due to invalid credentials");
AassertEquals(test.getStatus(), Status.FAIL);
BassertTrue(test.getStatus().equals("FAIL"));
CassertFalse(test.getStatus() == Status.PASS);
DassertNull(test.getStatus());
Attempts:
2 left
💡 Hint
Check the ExtentTest API for how status is represented.
🔧 Debug
advanced
2:00remaining
Why does this Extent Reports setup not generate any report file?
Review the following Java code snippet. Why does it fail to generate the Extent Report file?
Selenium Java
ExtentReports extent = new ExtentReports();
ExtentHtmlReporter htmlReporter = new ExtentHtmlReporter("report.html");
ExtentTest test = extent.createTest("Sample Test");
test.pass("Test passed");
// Missing extent.attachReporter(htmlReporter);
extent.flush();
ABecause flush() must be called before creating tests.
BBecause ExtentHtmlReporter requires a full file path, not just a file name.
CBecause test.pass() must be called after flush().
DBecause extent.attachReporter(htmlReporter) was not called, so no reporter is attached to write the report.
Attempts:
2 left
💡 Hint
Check if the reporter is attached to the ExtentReports object.
framework
advanced
2:00remaining
Which Extent Reports setup is best for parallel test execution in Selenium?
You want to run Selenium tests in parallel and generate a single Extent Report. Which setup ensures thread-safe logging?
ACreate a new ExtentReports instance inside each test thread without sharing, then merge reports manually.
BUse a ThreadLocal<ExtentTest> to store test instances per thread and attach a single ExtentReports instance with synchronized flush.
CUse static ExtentTest variables shared across threads without synchronization.
DCall extent.flush() after each test method without thread safety considerations.
Attempts:
2 left
💡 Hint
Think about how to keep test logs separate per thread safely.
🧠 Conceptual
expert
2:00remaining
What is the primary purpose of calling extent.flush() in Extent Reports?
In the Extent Reports lifecycle, what does the method extent.flush() do?
AIt initializes the ExtentReports object and prepares it for logging tests.
BIt resets all test statuses to default before starting new tests.
CIt writes all the logged test information to the report file and clears the internal buffer.
DIt closes the Selenium WebDriver session after tests complete.
Attempts:
2 left
💡 Hint
Think about when the report file gets updated with test results.