Skip to content
This repository has been archived by the owner on Jul 17, 2020. It is now read-only.

ExtentReports - replace exisiting = false throwing nullpointerexception when trying to append to exisiting report #589

Closed
pfowles opened this issue Aug 16, 2016 · 14 comments

Comments

@pfowles
Copy link

pfowles commented Aug 16, 2016

I'm using ExtentReports with selenium webdriver and have recently discovered a problem, yesterday(15th Aug 16) with ExtentReports replaceExisting variable throwing a java.lang.nullpointerexception when the report already exists

When running a testSuite or class in TestNG

@BeforeClass
     public void seleInit() {

        reportName = "DemoReport.html"; // name of report   
        report = ExtentManager.getInstance(filePath+reportName);`
... }

Where ExtentManager.get Instance

extent = new ExtentReports(filePath,false, DisplayOrder.OLDEST_FIRST, NetworkMode.ONLINE);

Deleting the report or changing replaceExisiting to true solves the issue but I lose previous occurrences of the test =>
extent = new ExtentReports(filePath,true, DisplayOrder.OLDEST_FIRST, NetworkMode.ONLINE);

The former extent code I would like to keep as it was originally working right up until yesterday

So was wondering how could this have occurred.

I am using ExtentReports 2.40

@anshooarora
Copy link
Owner

Can you share the stack-trace? Upgrade to 2.41.1 and try again?

@pfowles
Copy link
Author

pfowles commented Aug 16, 2016

FAILED CONFIGURATION: @BeforeClass seleInit
java.lang.NullPointerException
at com.relevantcodes.extentreports.converters.TestConverter.createTestList(TestConverter.java:46)
at com.relevantcodes.extentreports.ExtentReports.(ExtentReports.java:91)
at reportLibrary.ExtentManager.getInstance(ExtentManager.java:19)
at pcgss.AssistSearchTestCases.AssistSearch2.seleInit(AssistSearch2.java:101)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:85)
at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:510)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:211)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:138)
at org.testng.internal.TestMethodWorker.invokeBeforeClassMethods(TestMethodWorker.java:170)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:104)
at org.testng.TestRunner.privateRun(TestRunner.java:774)
at org.testng.TestRunner.run(TestRunner.java:624)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:359)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:354)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:312)
at org.testng.SuiteRunner.run(SuiteRunner.java:261)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1215)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1140)
at org.testng.TestNG.run(TestNG.java:1048)
at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:112)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:205)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:176)

@pfowles
Copy link
Author

pfowles commented Aug 16, 2016

Updated to new version of extentreports still not working?

@anshooarora
Copy link
Owner

anshooarora commented Aug 16, 2016

Are there any tests in the existing report?

@pfowles
Copy link
Author

pfowles commented Aug 16, 2016

one test from the last report technically its overwriting that test

@pfowles
Copy link
Author

pfowles commented Aug 16, 2016

FAILED CONFIGURATION: @BeforeClass seleInit
java.lang.NullPointerException
at com.relevantcodes.extentreports.converters.TestConverter.createTestList(TestConverter.java:81)
at com.relevantcodes.extentreports.ExtentReports.(ExtentReports.java:92)
at com.relevantcodes.extentreports.ExtentReports.(ExtentReports.java:374)
at reportLibrary.ExtentManager.getInstance(ExtentManager.java:21)
at pcgss.AssistSearchTestCases.AssistSearch2.seleInit(AssistSearch2.java:101)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:85)
at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:510)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:211)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:138)
at org.testng.internal.TestMethodWorker.invokeBeforeClassMethods(TestMethodWorker.java:170)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:104)
at org.testng.TestRunner.privateRun(TestRunner.java:774)
at org.testng.TestRunner.run(TestRunner.java:624)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:359)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:354)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:312)
at org.testng.SuiteRunner.run(SuiteRunner.java:261)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1215)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1140)
at org.testng.TestNG.run(TestNG.java:1048)
at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:112)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:205)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:176)

@pfowles
Copy link
Author

pfowles commented Aug 16, 2016

But its failing on initialisation

@pfowles
Copy link
Author

pfowles commented Aug 16, 2016

If I tell it to replaceExisting it works/ if I tell it not to it shows that stack trace - filepath is correct

@pfowles
Copy link
Author

pfowles commented Aug 16, 2016

I think this might be to do with copying testclasses as an old testclass in a different package still works

@anshooarora
Copy link
Owner

I think this might be to do with copying testclasses as an old testclass in a different package still works

So it works if when you change packages of your existing test class? That is strange.

@pfowles
Copy link
Author

pfowles commented Aug 16, 2016

I copied the testclass over to to the new (dodgy) package and it works maybe I hadn't cleaned the cache who knows

@anshooarora
Copy link
Owner

I will close this issue as it seems to be resolved. Feel free to reopen this or a new issue if you encounter it again.

@Pravin3M
Copy link

Hi Ansh,

I am getting nullpointer exception on below line. please let me know how to resolve.
extentReports = new ExtentReports(reportPath, false);

@ranadinesh786
Copy link

issue :

How to solve NULLPOINTEREXCEPTION while using grouping concepts in POM with Extends Reporting ?

Solutions:

       1. Use below parameters to all the configuration annotations which we are using i.e. in base test;
	(alwaysRun = true)
	2. Use valid try catch block inside the page class and don’t use throws [incorrect exception]
	3. Use parameterized values instead of taking hardcode values inside the page or script.****

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants