0
0
JUnittesting~20 mins

XML and HTML reports in JUnit - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
JUnit Report Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
1:30remaining
What is the output of this JUnit XML report snippet?
Given this XML snippet from a JUnit test report, what is the value of the attribute tests in the testsuite element?
JUnit
<testsuite name="CalculatorTests" tests="5" failures="1" errors="0" skipped="0">
  <testcase classname="CalculatorTests" name="testAdd" time="0.01"/>
  <testcase classname="CalculatorTests" name="testSubtract" time="0.01">
    <failure message="expected:&lt;5&gt; but was:&lt;3&gt;" type="AssertionError"/>
  </testcase>
  <testcase classname="CalculatorTests" name="testMultiply" time="0.01"/>
  <testcase classname="CalculatorTests" name="testDivide" time="0.01"/>
  <testcase classname="CalculatorTests" name="testModulo" time="0.01"/>
</testsuite>
A5
B4
C1
D0
Attempts:
2 left
💡 Hint
Look at the tests attribute inside the testsuite tag.
assertion
intermediate
1:30remaining
Which assertion correctly checks if the HTML report contains the summary of failed tests?
You have generated an HTML report from JUnit XML. Which assertion correctly verifies that the report contains the text showing the number of failed tests as 2?
JUnit
String htmlReport = "<html><body><div id='summary'>Tests run: 10, Failures: 2, Errors: 0</div></body></html>";
AassertEquals(htmlReport, "Failures: 2");
BassertTrue(htmlReport.contains("Failures: 2"));
CassertFalse(htmlReport.contains("Failures: 2"));
DassertNull(htmlReport);
Attempts:
2 left
💡 Hint
Check if the string contains the expected substring.
🔧 Debug
advanced
2:00remaining
Why does this JUnit XML report fail to show any test cases in the HTML report?
Given this XML snippet, the generated HTML report shows zero tests run. What is the likely cause?
JUnit
<testsuite name="SampleTests" tests="0" failures="0" errors="0" skipped="0">
</testsuite>
AThe <code>tests</code> attribute is zero, so no test cases are recorded.
BThe <code>failures</code> attribute should be greater than zero to show tests.
CThe <code>skipped</code> attribute must be set to zero explicitly.
DThe <code>errors</code> attribute is missing, causing the report to fail.
Attempts:
2 left
💡 Hint
Look at the tests attribute value.
framework
advanced
1:30remaining
Which tool is commonly used to convert JUnit XML reports into readable HTML reports?
You want to generate an HTML report from JUnit XML test results. Which tool or plugin is most commonly used for this purpose?
AMockito Framework
BJUnit Jupiter Engine
CTestNG XML Parser
DSurefire Report Plugin
Attempts:
2 left
💡 Hint
Look for a Maven plugin that generates reports.
🧠 Conceptual
expert
2:00remaining
What is the main advantage of using XML reports for automated test results?
Why do automated testing frameworks often output test results in XML format like JUnit XML?
AXML reports reduce the test execution time significantly.
BXML reports are human-readable and require no additional tools to interpret.
CXML reports provide a standardized, machine-readable format that can be easily parsed and transformed into other formats like HTML.
DXML reports automatically fix test failures when parsed.
Attempts:
2 left
💡 Hint
Think about why machines prefer XML for data exchange.