Bird
Raised Fist0
Selenium Javatesting~20 mins

TestNG default reports in Selenium Java - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
TestNG Report Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate
2:00remaining
TestNG Default Report: Passed Tests Count
Given the following TestNG test class, what will be the count of passed tests shown in the default TestNG report after execution?
Selenium Java
import org.testng.annotations.Test;

public class SampleTest {
    @Test
    public void testA() {
        assert true;
    }

    @Test
    public void testB() {
        assert true;
    }

    @Test
    public void testC() {
        assert false;
    }
}
A3
B0
C2
D1
Attempts:
2 left
💡 Hint
Remember that tests with failed assertions are not counted as passed.
❓ assertion
intermediate
2:00remaining
Assertion in TestNG Default Report for Skipped Tests
If a test method is annotated with @Test and depends on another test that fails, what will the default TestNG report show for the dependent test?
Selenium Java
import org.testng.annotations.Test;

public class DependencyTest {
    @Test
    public void test1() {
        assert false;
    }

    @Test(dependsOnMethods = {"test1"})
    public void test2() {
        assert true;
    }
}
Atest2 is marked as passed in the report
Btest2 is marked as skipped in the report
Ctest2 is marked as failed in the report
Dtest2 is not shown in the report
Attempts:
2 left
💡 Hint
Think about what happens when a dependency test fails in TestNG.
🔧 Debug
advanced
2:00remaining
Debugging Missing Test Results in TestNG Default Report
A tester notices that some test methods are not appearing in the TestNG default report after execution. Which of the following is the most likely cause?
ATest methods have assertions that always pass
BTest methods throw exceptions but are still marked as @Test
CTest methods are private instead of public
DTest methods are missing the @Test annotation
Attempts:
2 left
💡 Hint
TestNG only recognizes methods with a specific annotation as tests.
🧠 Conceptual
advanced
2:00remaining
Understanding TestNG Default Report Structure
Which section is NOT part of the default TestNG HTML report generated after test execution?
ACode coverage percentage for tested classes
BDetailed stack trace for failed tests
CSummary of passed, failed, and skipped tests
DTest execution time for each test method
Attempts:
2 left
💡 Hint
Think about what TestNG reports by default without extra tools.
❓ framework
expert
3:00remaining
Customizing TestNG Default Reports
Which of the following is the correct way to add custom logging information to the TestNG default report?
AImplement ITestListener and override onTestSuccess to add logs
BModify the testng.xml file to include custom log tags
CAdd System.out.println statements inside test methods
DUse @Listeners annotation to disable default reports and write logs
Attempts:
2 left
💡 Hint
TestNG allows listeners to hook into test events for custom behavior.

Practice

(1/5)
1. What is the main purpose of TestNG default reports?
easy
A. To write custom test cases manually
B. To automatically show test results after running tests
C. To compile Java code before testing
D. To create database backups

Solution

  1. Step 1: Understand what TestNG default reports do

    TestNG default reports automatically display the results of tests after execution without extra coding.
  2. Step 2: Compare options with this function

    Only To automatically show test results after running tests matches this description; others describe unrelated tasks.
  3. Final Answer:

    To automatically show test results after running tests -> Option B
  4. Quick Check:

    TestNG default reports = automatic test result display [OK]
Hint: Default reports show results automatically after tests run [OK]
Common Mistakes:
  • Thinking reports require extra code
  • Confusing reports with code compilation
  • Assuming reports manage databases
2. Which file is generated by TestNG by default to show test results?
easy
A. test-output/index.html
B. src/test/java/Test.java
C. pom.xml
D. log.txt

Solution

  1. Step 1: Identify the default report file location

    TestNG generates reports inside the 'test-output' folder, with 'index.html' as the main report file.
  2. Step 2: Check other options for correctness

    Other files are unrelated: source code, build config, or logs.
  3. Final Answer:

    test-output/index.html -> Option A
  4. Quick Check:

    Default report file = test-output/index.html [OK]
Hint: Look inside test-output folder for default reports [OK]
Common Mistakes:
  • Confusing source code files with report files
  • Expecting reports in pom.xml or logs
  • Not checking the test-output directory
3. Given this TestNG test run, what will the default report show if one test fails and two pass?
medium
A. Passed: 2, Failed: 1, Skipped: 0
B. Passed: 3, Failed: 0, Skipped: 0
C. Passed: 1, Failed: 2, Skipped: 0
D. Passed: 0, Failed: 3, Skipped: 0

Solution

  1. Step 1: Analyze the test results given

    There are two tests that passed and one test that failed.
  2. Step 2: Match the counts to the report format

    The report shows counts as Passed: 2, Failed: 1, Skipped: 0.
  3. Final Answer:

    Passed: 2, Failed: 1, Skipped: 0 -> Option A
  4. Quick Check:

    Test counts in report = Passed 2, Failed 1 [OK]
Hint: Count tests passed and failed to match report summary [OK]
Common Mistakes:
  • Mixing passed and failed counts
  • Assuming skipped tests when none exist
  • Misreading the test result numbers
4. You ran TestNG tests but the default report shows no tests executed. What is the likely cause?
medium
A. Java version is outdated
B. TestNG jar file is corrupted
C. Report folder is manually deleted
D. Test methods are missing the @Test annotation

Solution

  1. Step 1: Understand why no tests run

    If test methods lack the @Test annotation, TestNG will not recognize or run them.
  2. Step 2: Evaluate other options

    Corrupted jar or Java version issues usually cause errors, not silent no tests. Deleting report folder does not affect test execution.
  3. Final Answer:

    Test methods are missing the @Test annotation -> Option D
  4. Quick Check:

    No @Test annotation = no tests run [OK]
Hint: Check @Test annotation on test methods first [OK]
Common Mistakes:
  • Assuming report folder deletion stops tests
  • Blaming Java version without error messages
  • Ignoring missing @Test annotations
5. How can you customize the TestNG default report to include screenshots on failure?
hard
A. By disabling default reports and writing logs to console only
B. By editing the test-output/index.html file manually after tests run
C. By adding listeners and embedding screenshots in the report via ITestListener
D. By renaming the test-output folder before running tests

Solution

  1. Step 1: Understand default report customization

    TestNG default reports do not support screenshots by default; customization requires listeners like ITestListener.
  2. Step 2: Evaluate options for adding screenshots

    Adding listeners to capture screenshots on failure and embed them is the correct approach. Manual editing or renaming folders won't add screenshots. Disabling reports removes them entirely.
  3. Final Answer:

    By adding listeners and embedding screenshots in the report via ITestListener -> Option C
  4. Quick Check:

    Use ITestListener to add screenshots [OK]
Hint: Use ITestListener to add screenshots on failure [OK]
Common Mistakes:
  • Trying to edit report files manually
  • Renaming folders expecting new features
  • Disabling reports instead of customizing
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard