In TestNG Framework, TestBase class, the ITestResult object itResult is giving RuntimeException | Selenium Forum
P
Pravin V. Kumbhare Posted on 12/08/2020

I'm practicing the TestNG framework, and as demonstrated in video 1 of same, I'm trying to get the name of @Test method in @BeforeTest function, using the object "itResult" of the interface "ITestResult". The output is RuntimeException and I'm not able to get the name of calling Test.

Below is my @BeforeMethod function:

@BeforeMethod
public ExtentTest initRep(ITestResult itResult) {
System.out.println(itResult.getMethod().getMethodName().toUpperCase());
extRep = InitUtility.initUtil();
exTest = extRep.createTest(itResult.getMethod().getMethodName().toUpperCase());
return exTest;
}

On executing, RuntimeException is thrown with no explanation.

Below is the console output:

[TestNG] Running:
C:\Users\kbawankar\AppData\Local\Temp\testng-eclipse--123686319\testng-customsuite.xml

FAILED: testA
java.lang.RuntimeException
at org.testng.internal.TestResult.toString(TestResult.java:245)
at org.testng.internal.TestResult.toString(TestResult.java:230)
at org.testng.remote.strprotocol.TestResultMessage.toString(TestResultMessage.java:330)
at org.testng.remote.strprotocol.TestResultMessage.<init>(TestResultMessage.java:114)
at org.testng.remote.strprotocol.TestResultMessage.<init>(TestResultMessage.java:124)
at org.testng.remote.strprotocol.RemoteTestListener.onTestFailure(RemoteTestListener.java:72)
at org.testng.remote.strprotocol.RemoteTestListener.onConfigurationFailure(RemoteTestListener.java:102)
at org.testng.internal.Invoker.runConfigurationListeners(Invoker.java:1770)
at org.testng.internal.Invoker.handleConfigurationFailure(Invoker.java:303)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:237)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:601)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:845)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1153)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:125)
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:1199)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1124)
at org.testng.TestNG.run(TestNG.java:1032)
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)


===============================================
Default test
Tests run: 1, Failures: 1, Skips: 0
===============================================


===============================================
Default suite
Total tests run: 1, Failures: 1, Skips: 0
===============================================

[TestNG] Time taken by org.testng.reporters.JUnitReportReporter@244038d0: 9 ms
[TestNG] Time taken by org.testng.reporters.EmailableReporter2@33833882: 7 ms
[TestNG] Time taken by org.testng.reporters.XMLReporter@73a28541: 6 ms
[TestNG] Reporter org.testng.reporters.jq.Main@53bd815b failed
java.lang.RuntimeException
at org.testng.internal.TestResult.toString(TestResult.java:245)
at org.testng.internal.TestResult.toString(TestResult.java:230)
at org.testng.internal.Utils.toString(Utils.java:834)
at org.testng.reporters.jq.Model.getTestResultName(Model.java:146)
at org.testng.reporters.jq.ChronologicalPanel.getContent(ChronologicalPanel.java:67)
at org.testng.reporters.jq.BaseMultiSuitePanel.generate(BaseMultiSuitePanel.java:24)
at org.testng.reporters.jq.Main.generateReport(Main.java:63)
at org.testng.TestNG.generateReports(TestNG.java:1090)
at org.testng.TestNG.run(TestNG.java:1049)
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)
[TestNG] Time taken by [FailedReporter passed=0 failed=0 skipped=0]: 12 ms
[TestNG] Time taken by org.testng.reporters.SuiteHTMLReporter@76ccd017: 74 ms


T
tanveer Replied on 12/08/2020

same error i also got


A
Ashish Replied on 15/08/2020

Can you zip and attach the project?


Related Posts