I m trying to implement Extent Reports but getting Null Pointer Exception. If i am running this code, without using Extent Report functionality it’s working fine. Kindly help. l
New Driver launched with browser
java.lang.NullPointerException: Cannot invoke "com.aventstack.extentreports.ExtentTest.log(com.aventstack.extentreports.Status, String)" because "com.weirdo.listeners.ExtentListeners.test" is null
at com.weirdo.base.Page.<init>(Page.java:121)
at com.weirdo.utilities.ExcelReader.<init>(ExcelReader.java:39)
at com.weirdo.base.Page.<clinit>(Page.java:48)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)
**Below are my implementation**
**ExtentReport implementation part:**
public class ExtentManager {
private static ExtentReports extent;
public static String fileName;
public static ExtentReports createInstance() {
if(extent==null)
{
Date d = new Date();
String reportName = "Extent_"+d.toString().replace(":", "_").replace(" ", "_") +".html";
ExtentSparkReporter htmlReporter = new ExtentSparkReporter(".\reports\" + reportName);
htmlReporter.config().setTheme(Theme.STANDARD);
htmlReporter.config().setDocumentTitle("POM Framework");
htmlReporter.config().setEncoding("utf-8");
htmlReporter.config().setReportName("POM Framework");
extent = new ExtentReports();
extent.attachReporter(htmlReporter);
extent.setSystemInfo("Automation Tester", "*****");
extent.setSystemInfo("Organization", "xyxy");
}
return extent;
}