This program sets up Extent Reports, creates two test cases with pass and fail steps, and saves the report as testReport.html.
import com.aventstack.extentreports.ExtentReports;
import com.aventstack.extentreports.ExtentTest;
import com.aventstack.extentreports.reporter.ExtentHtmlReporter;
public class ExtentReportSetup {
public static void main(String[] args) {
ExtentHtmlReporter htmlReporter = new ExtentHtmlReporter("testReport.html");
ExtentReports extent = new ExtentReports();
extent.attachReporter(htmlReporter);
ExtentTest test1 = extent.createTest("Google Search Test", "Test Google search functionality");
test1.pass("Navigated to Google homepage");
test1.pass("Entered search text");
test1.pass("Search results displayed successfully");
ExtentTest test2 = extent.createTest("Login Test", "Test login with invalid credentials");
test2.fail("Login failed due to wrong password");
extent.flush();
System.out.println("Report generated: testReport.html");
}
}