0
0
Selenium Javatesting~8 mins

TestNG default reports in Selenium Java - Framework Patterns

Choose your learning style9 modes available
Framework Mode - TestNG default reports
Folder Structure
src/
 └── test/
      └── java/
           └── com/
                └── example/
                     ├── pages/
                     │    └── LoginPage.java
                     ├── tests/
                     │    └── LoginTest.java
                     ├── utils/
                     │    └── WebDriverFactory.java
                     └── config/
                          └── TestConfig.java

test-output/  <-- Generated by TestNG after test run, contains default reports
Test Framework Layers
  • Driver Layer: Manages browser setup and teardown (e.g., WebDriverFactory.java).
  • Page Objects: Encapsulate UI elements and actions (e.g., LoginPage.java).
  • Test Layer: Contains TestNG test classes with @Test methods (e.g., LoginTest.java).
  • Utilities: Helper classes for common functions (e.g., waits, logging).
  • Configuration: Holds environment settings and test parameters (e.g., TestConfig.java).
Configuration Patterns
  • testng.xml: Defines test suites, groups, parameters like browser and environment.
  • Property Files: Store URLs, credentials, and environment-specific data.
  • System Properties: Override config via command line for CI flexibility.
  • WebDriver Setup: Use factory pattern to select browser based on config.
Test Reporting and CI/CD Integration
  • TestNG Default Reports: Generated automatically in test-output/ folder after test run.
  • Includes index.html with summary of passed, failed, skipped tests.
  • Reports show test method details, execution time, and stack traces for failures.
  • Integrate with CI tools (Jenkins, GitHub Actions) to archive and display reports.
  • Use testng.xml listeners to extend reporting if needed.
Best Practices for TestNG Default Reports
  1. Keep tests independent to get clear pass/fail results in reports.
  2. Use meaningful test method names for easy understanding in reports.
  3. Configure testng.xml to organize tests logically for better report grouping.
  4. Regularly clean test-output/ folder to avoid stale report data.
  5. Use listeners to capture screenshots on failure and link them in reports.
Self Check

Where in this folder structure would you add a new page object class for the "Dashboard" page?

Key Result
TestNG default reports are auto-generated HTML summaries in the test-output folder showing test results after execution.