java.lang.NullPointerException
at runnerClasses.Class1.meth1(Class1.java:106)
at runnerClasses.Class2.meth2(Class2.java:72)
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:498)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:108)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:661)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:869)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1193)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:126)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:109)
at org.testng.TestRunner.privateRun(TestRunner.java:744)
at org.testng.TestRunner.run(TestRunner.java:602)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:380)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:375)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:340)
at org.testng.SuiteRunner.run(SuiteRunner.java:289)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1301)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1226)
at org.testng.TestNG.runSuites(TestNG.java:1144)
at org.testng.TestNG.run(TestNG.java:1115)
at org.testng.IDEARemoteTestNG.run(IDEARemoteTestNG.java:72)
at org.testng.RemoteTestNGStarter.main(RemoteTestNGStarter.java:123)
这是代码
public class Class1Method1{
public ExtentReports report;
ExtentTest logger;
@BeforeClass
public void somemeth(){
report = new ExtentReports(System.getProperty("user.dir") + "\\src\\test\\java\\Reports\\TestReport.html", false, DisplayOrder.NEWEST_FIRST);
report.loadConfig(new File(System.getProperty("user.dir") + "\\src\\test\\java\\Reports\\extent-config.xml"));
logger = report.startTest("desc", "Test1");
}
@Test()
public void meth1(String some1){
logger.log(LogStatus.PASS, "desc");
}
@AfterClass
public void afterreports(){
report.flush();
driver.quit();
}
}
Class2Method2{
public ExtentReports report;
ExtentTest logger;
@BeforeClass
public void somemeth1(){
report = new ExtentReports(System.getProperty("user.dir") + "\\src\\test\\java\\Reports\\TestReport.html", false, DisplayOrder.NEWEST_FIRST);
report.loadConfig(new File(System.getProperty("user.dir") + "\\src\\test\\java\\Reports\\extent-config.xml"));
logger = report.startTest("desc", "Test1");
}
@Test()
public void meth2() throws InterruptedException {
class1.meth1("Para1")
}
@AfterClass
public void afterreports(){
report.flush();
driver.quit();
}
}
当记录器在从方法(类 2)调用的方法(类 1)中时,范围报告 2.41 抛出空指针范围记录器在类 1 的方法中,该方法在类 2 的方法中被调用。如果我在 Class1Method1 中评论范围报告记录器,代码运行良好..我错过了什么???
不能再在这里编辑了……