当记录器处于从方法(类2)调用的方法(类1)中时,扩展区报告2.41抛出空指针

时间:2018-07-09 00:15:29

标签: selenium selenium-webdriver extentreports selenium-extent-report

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.41在记录器处于从方法(类2)调用的方法(类1)中时抛出空指针 范围记录器在class1的方法中,而在class2的方法中被调用。 如果我在Class1Method1中注释了范围报告记录器,则代码会很好..我遗漏了一些东西?

无法再在此处进行编辑...

0 个答案:

没有答案