Getting NullPointer Exception while running Extent Reports | Selenium Forum
saiteja Posted on 09/11/2021

I am getting java.lang.Null Pointer Exception whenever the program entered to test.log line test base class. And I am not able to debug the code as it is first line of code.


[RemoteTestNG] detected TestNG version 7.3.0
[TestNGContentHandler] [WARN] It is strongly recommended to add "<!DOCTYPE suite SYSTEM "" >" at the top of your file, otherwise TestNG may fail or not work as expected.
FAILED CONFIGURATION: @BeforeTest beforeTest(org.testng.TestRunner@5762806e)
at testbase.BaseTest.beforeTest(
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(
at sun.reflect.DelegatingMethodAccessorImpl.invoke(
at java.lang.reflect.Method.invoke(
at org.testng.internal.MethodInvocationHelper.invokeMethod(
at org.testng.internal.MethodInvocationHelper.invokeMethodConsideringTimeout(
at org.testng.internal.ConfigInvoker.invokeConfigurationMethod(
at org.testng.internal.ConfigInvoker.invokeConfigurations(
at org.testng.TestRunner.invokeTestConfigurations(
at org.testng.TestRunner.beforeRun(
at org.testng.SuiteRunner.runTest(
at org.testng.SuiteRunner.runSequentially(
at org.testng.SuiteRunner.privateRun(
at org.testng.SuiteRunnerWorker.runSuite(
at org.testng.TestNG.runSuitesSequentially(
at org.testng.TestNG.runSuitesLocally(
at org.testng.TestNG.runSuites(
at org.testng.remote.RemoteTestNG.initAndRun(
at org.testng.remote.RemoteTestNG.main(


Note: Observed a similar exception in TestNG 7.0 also.

Working with Ubuntu Operating system.


Program :

public Application app;
public SoftAssert assertion;
public String actualvalue;
public String expectedvalue;
public ExtentReports rep;
public ExtentTest test;

@BeforeTest(alwaysRun =true)
public void beforeTest(ITestContext context) throws InterruptedException
test.log(Status.INFO, "Welcome to logging"); ------------------------------------------------- Getting error on this line
app = new Application();

// 1 app keyword object for entire test -All @Test
context.setAttribute("app", app);
//app.log("Browser Opened");
assertion= new SoftAssert();

//init and share it with all tests
rep =ExtentManager.getReports();
test =rep.createTest("Upload And Download Settings");
test.log(Status.INFO,"Starting Test"+context.getCurrentXmlTest().getName());
context.setAttribute("report", rep);
context.setAttribute("test", test);



Ashish Replied on 25/11/2021

You have not initialized the test object.

You need to initialize the test object in order to work with it.

So you are getting null pointer exception

Related Posts