Extent Reports
Why Use Extent Reports?
Extent Reports generate a professional HTML report containing:
- Step-wise execution logs
- Pass and Fail status
- Screenshots for failed test cases
These reports are easy to share with stakeholders and provide a clear execution summary.
Framework Integration
Extent Reports are integrated into the BaseTest class.
The execution flow includes:
- Initialize the report before the test suite starts.
- Create a separate test entry for every test method.
- Log every execution step.
- Attach screenshots whenever a test fails.
- Flush the report after execution to generate the HTML report.
This transforms raw execution results into a readable and professional report.
Log4j Logging
Why Use Log4j?
Logging helps monitor automation execution in real time.
Logs provide information such as:
- Browser launch
- Application navigation
- Page actions
- Test execution flow
- Assertions
- Failure details
Logs are especially useful when tests run in CI/CD environments where browser execution is not visible.
Configuration
Logging is configured using:
log4j2.xml
The configuration includes:
- Console Appender
- File Appender
- Log Levels
Every execution produces a complete execution trail for debugging and analysis.
Parallel Execution (TestNG)
Why Use Parallel Execution?
Parallel execution reduces overall automation execution time by running multiple tests simultaneously.
Instead of executing tests one after another, TestNG executes multiple test classes in parallel.
TestNG Configuration
Parallel execution is configured inside the testng.xml file.
<suite
name="EcommerceSuite"
parallel="tests"
thread-count="3">
Thread Safety
Each parallel thread should maintain its own WebDriver instance.
The framework follows the ThreadLocal approach for thread-safe browser execution.
Screenshots on Failure
Why Capture Screenshots?
Screenshots provide visual evidence whenever a test case fails.
Benefits include:
- Easier debugging
- Faster defect analysis
- Better reporting
- Proof of failure
Screenshot Storage
Failed screenshots are:
- Captured inside @AfterMethod
- Saved inside the Screenshots folder
- Attached to the Extent Report
Screenshots are generated only for failed test cases.
Screenshot Utility
public class ScreenshotUtil {
public static void captureScreenshot(WebDriver driver,
String testName) {
TakesScreenshot ts = (TakesScreenshot) driver;
File src = ts.getScreenshotAs(OutputType.FILE);
File dest = new File(
"Screenshots/" + testName + ".png"
);
// Copy src to dest
// Commons IO FileUtils
}
}
Execution Flow
The Screenshot Utility is called from the @AfterMethod only when the test execution status is Failure.
Passing test cases do not generate screenshots.
Data-Driven Testing
The framework supports multiple external data sources.
Excel Data
Excel data is managed using:
- Apache POI
- ExcelUtil.java
Multiple datasets can be executed using the same automation script without changing the code.
JSON Data
JSON files are supported using:
- ConfigReader
- Gson
- Jackson
JSON is used for:
- Configuration
- Test Data
- Environment Values
Benefits
Keeping test data outside the automation scripts provides:
- Better maintainability
- Improved reusability
- Easy test data updates
- Greater execution flexibility
Jenkins CI/CD
Jenkins Pipeline
The framework supports Jenkins Continuous Integration and Continuous Deployment.
The execution pipeline includes:
Checkout Code
↓
Build Project
↓
Execute TestNG Tests
↓
Generate Extent Report
↓
Archive HTML Reports
CI/CD Workflow
Whenever code is pushed:
- Jenkins pulls the latest code.
- Maven builds the project.
- TestNG executes all automation tests.
- Extent Reports are generated.
- HTML reports are archived for future reference.
This enables automatic execution on every build.
Real-Time Benefits
The complete framework provides several production-ready capabilities.
Parallel Execution
- Faster execution
- Reduced regression time
Screenshots
- Faster debugging
- Visual proof of failures
Extent Reports
- Professional HTML reports
- Step-by-step execution logs
- Easy stakeholder sharing
Log4j
- Complete execution logs
- Better troubleshooting
Data-Driven Testing
- Maximum test coverage
- Reusable automation scripts
- Externalized test data
Jenkins CI/CD
- Automatic execution
- Continuous testing
- Build verification
- Easy report access
Overall Framework Benefits
The framework is:
- Scalable
- Maintainable
- Reusable
- Production Ready
- Industry Standard
Frequently Asked Questions
Why are Extent Reports used?
Extent Reports generate professional HTML execution reports with:
- Step-wise logging
- Pass and Fail status
- Screenshots
- Easy sharing with stakeholders
How is Parallel Execution configured?
Parallel execution is configured in testng.xml using:
parallel="tests"thread-count="3"
Each thread should maintain its own WebDriver instance.
How are screenshots captured on failure?
The framework uses ScreenshotUtil.java.
Screenshots are:
- Captured using TakesScreenshot
- Saved inside the Screenshots folder
- Triggered from @AfterMethod
- Attached to the Extent Report
Which data sources are supported?
The framework supports:
- Excel using Apache POI
- JSON using Gson or Jackson
Both approaches keep test data separate from automation code.
What are the Jenkins pipeline stages?
The execution flow includes:
- Checkout Code
- Build Project
- Execute Test Cases
- Generate Reports
- Archive HTML Reports