0
0
Selenium Javatesting~8 mins

Extent Reports setup in Selenium Java - Framework Patterns

Choose your learning style9 modes available
Framework Mode - Extent Reports setup
Folder Structure
src/
├── main/
│   └── java/
│       └── com/example/project/
│           └── pages/                 # Page Object classes
├── test/
│   └── java/
│       └── com/example/project/tests/ # Test classes
│       └── com/example/project/utils/ # Utility classes (e.g., ExtentManager)
│       └── com/example/project/config/ # Configuration classes
└── resources/
    └── config.properties             # Environment and browser settings
Test Framework Layers
  • Driver Layer: Manages WebDriver setup and teardown.
  • Page Objects: Encapsulate UI elements and actions for each page.
  • Tests: Test classes using TestNG or JUnit to run test cases.
  • Utilities: Helper classes including ExtentManager to configure and provide ExtentReports instance.
  • Configuration: Properties files and classes to manage environment, browser, and credentials.
Configuration Patterns
  • config.properties: Store environment URLs, browser types, and credentials.
  • ConfigReader class: Reads properties file and provides values to tests and utilities.
  • ExtentManager utility: Creates and configures ExtentReports instance with report path, system info, and theme.
  • Test Listeners: Implement TestNG listeners to start and flush ExtentReports on test start and finish.
Test Reporting and CI/CD Integration
  • ExtentReports generates detailed HTML reports with test status, logs, screenshots, and timestamps.
  • Reports saved in test-output/extent-reports/ folder for easy access.
  • Integrate report generation in CI/CD pipelines (e.g., Jenkins) to publish reports after test runs.
  • Use TestNG listeners to automatically attach ExtentReports lifecycle to test execution.
Best Practices for Extent Reports Setup
  • Use a singleton pattern in ExtentManager to avoid multiple report instances.
  • Keep report configuration centralized for easy updates (e.g., report path, theme).
  • Attach screenshots on test failure to improve debugging.
  • Use TestNG listeners to separate reporting logic from test logic.
  • Clean old reports before new test runs to avoid confusion.
Self Check

Where in this folder structure would you add a new utility class to capture screenshots for ExtentReports?

Key Result
Organize Selenium Java tests with Page Objects, utilities like ExtentManager, and TestNG listeners for clean Extent Reports integration.