2017-11-24 19 views
0

범위 보고서를 생성하려고 할 때이 오류가 발생합니다. reports.endTest (test);로 이미 보고서를 닫았습니다. .범위 보고서가 throw 됨 테스트가 EndTest를 사용하여 안전하게 끝날 수 있기 전에 Close가 호출되었습니다.

이 공공 무효 beforeMethod (방법 방법) { 테스트 = reports.startTest ((this.getClass() getSimpleName() + ":"+ method.getName을 @BeforeMethod : 여기

내 코드입니다()), method.getName()); test.assignAuthor ("Roy"); test.assignCategory ("SMOKE TEST"); }

@Test(priority = 0) 
public static void initialSetup() throws InterruptedException, IOException { 
    System.setProperty("webdriver.ie.driver", "\\IEDriverServer.exe"); 
    b = new InternetExplorerDriver(); 

    b.get("https://something.com"); 
    Alert alert = b.switchTo().alert(); 

    String _user_name = "kirstie"; 
    String _password = "88525"; 
    alert.authenticateUsing(new UserAndPassword(_user_name, _password)); 
    b.switchTo().defaultContent(); 

} 

@Test(priority = 1, enabled = true) 
public static void secondClient() throws Exception { 

    b.findElement(By.xpath("//*[@class='main-sidebar open']")).click(); 

    b.findElement(By.xpath("//*[@class='sub-menu group open']/li")).click(); 

} 

@AfterMethod 
public void afterMethod(ITestResult iTestResult) throws IOException { 

    if (iTestResult.getStatus() == ITestResult.FAILURE) { 
     String screenshotPath = GetScreenshot.capture(driver, "screenShots"); 
     test.log(LogStatus.FAIL, "Screenshot", test.addScreenCapture(screenshotPath)); 
     test.log(LogStatus.FAIL, "Test Case Failed is " + iTestResult.getName()); 
     test.log(LogStatus.FAIL, "Test Case Failed is " + iTestResult.getThrowable()); 
    } else if (iTestResult.getStatus() == ITestResult.SKIP) { 
     test.log(LogStatus.SKIP, "Test Case Skipped is " + iTestResult.getName()); 
    } 
    reports.endTest(test); 
} 

@AfterSuite 
public void afterSuite() { 

    reports.flush(); 
    reports.close(); 
} 
+0

는 정보를 원하시면 다음 링크를 참조하십시오 사용하여 해결할 수 내 project.Hope 사용 된 템플릿 붙여 넣기 : [링크] (HTTPS : /을 /stackoverflow.com/questions/40220370/extent-report-report-endtesttest-method) –

답변

0

난 그냥 복사 나는 당신의 문제가이

WebDriver driver; 
    ExtentHtmlReporter htmlReporter; 
    ExtentReports extent; 
    ExtentTest test; 



      @BeforeTest 
      public void setUp() { 
       // where we need to generate the report 

       htmlReporter = new ExtentHtmlReporter("Your report Path"); 
       extent = new ExtentReports(); 
       extent.attachReporter(htmlReporter); 
       // Set our document title, theme etc.. 
       htmlReporter.config().setDocumentTitle("Rentalhomes"); 
       htmlReporter.config().setReportName("Rentalhomes Production Testing"); 
       htmlReporter.config().setTestViewChartLocation(ChartLocation.TOP); 
       htmlReporter.config().setTheme(Theme.DARK); 


          } 
      } 
      @Test 
      public void HomepageLogo() throws Exception { 
       test = extent.createTest("rentalhomesHomePage"); 
       //Your Test 

      } 

      @AfterMethod 
      public void setTestResult(ITestResult result) throws IOException { 


       if (result.getStatus() == ITestResult.FAILURE) { 
        test.log(Status.FAIL, result.getName()); 
        test.log(Status.FAIL,result.getThrowable()); 
        //test.fail("Screen Shot : " + test.addScreenCaptureFromPath(screenShot)); 
       } else if (result.getStatus() == ITestResult.SUCCESS) { 
        test.log(Status.PASS, result.getName()); 
        //test.pass("Screen Shot : " + test.addScreenCaptureFromPath(screenShot)); 
       } else if (result.getStatus() == ITestResult.SKIP) { 
        test.skip("Test Case : " + result.getName() + " has been skipped"); 
       } 

       extent.flush(); 
      driver.close(); 

      } 
     }