java.lang.NullPointerException + Test NG

<!DOCTYPE suite SYSTEM “http://testng.org/testng-1.0.dtd” >

<suite name=”Idexx SmartService Enterprise” verbose=”10″ preserve-order=”true”>
<parameter name=”userName_Xml” value=”test1″/>
<parameter name=”password_Xml” value=”test1″/>
<parameter name=”transferFile_Xml” value=”Transfer File To Enterprise”/>
<parameter name=”advancedfileSearch_Xml” value=”Advanced File Search”/>
<parameter name=”infileshare_Xml” value=”IN_FILE_SHARE”/>

<test name=”IPU Advanced File Search Functionality”>
<parameter name=”practiceSAP_Xml” value=”123089″/>
<parameter name=”deviceSerialNo_Xml” value=”IPUDVPQJQ1″/>
<parameter name=”deviceId_Xml” value=”IPUDVPQJQ1″/>
<classes>
<class name=”testng.filestab.AdvancedFileSearch_TestNG”/>
</classes>
</test>
<test name=”IVLS Advanced File Search Functionality”>
<parameter name=”practiceSAP_Xml” value=”110606″/>
<parameter name=”deviceSerialNo_Xml” value=”VS582PY12″/>
<parameter name=”deviceId_Xml” value=”VS582PY12″/>
<classes>
<class name=”testng.filestab.AdvancedFileSearch_TestNG”/>
</classes>
</test>
</suite>

When I run the above suite file, always only the last test tag is executed (here, test name=”IVLS Advanced File Search Functionality”), irrespective of how many test tags are present. I have debugged, I could not find the solution.

In output i get

java.lang.NullPointerException
at testng.filestab.AdvancedFileSearch_TestNG.LoginPage(AdvancedFileSearch_TestNG.java:62)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:85)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:648)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:834)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1142)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:124)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:108)
at org.testng.TestRunner.privateRun(TestRunner.java:771)
at org.testng.TestRunner.run(TestRunner.java:621)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:357)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:352)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:310)
at org.testng.SuiteRunner.run(SuiteRunner.java:259)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1176)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1101)
at org.testng.TestNG.run(TestNG.java:1009)
at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:111)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:204)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:175)

Can you try giving an unique class name for each test.

Can you provide a snapshot of your project along with test file which the xml is referring to for a better view .

on August 11, 2015.
Add Comment
  • 1 Answer(s)

    Can you tell me what the code line on line 62 in AdvancedFileSearch_TestNG.java:62 . This is where you are getting null pointer.

    Virender

    Professor Answered on August 13, 2015.

    +

    on August 14, 2015.
    Add Comment
  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.