Закрытие перед вызовом endTest в Selenium с использованием Extent Reports - PullRequest
0 голосов
/ 31 мая 2018

BaseTest.java:

private static ReportService reportService; // Calling report service interface

@BeforeSuite:
reportService = new ExtentReportService(getConfig()); // New instance of ExtentReportService.

@BeforeMethod:
reportService.startTest(testname); // Starting the test and passing the name and description of the test.

@AfterMethod:
reportService.endTest(); // Ending the test

@AfterSuite:
reportService.close(); // Closing the test

**ExtentReportService.java:** // Contains different extent API methods. (These are designed to be generic.)

protected static ExtentReports extent; // static instance of ExtentReports
protected static ExtentTest test; //static instance of ExtentTTest

@Override // StartTest method
startTest(Method method) {
testMetaData = getTestMetaData(method);
test=extent.startTest(testMetaData.getId(),testMetaData.getSummary());
}

@Override //End test method
endTest() {
extent.endTest(test);
extent.flush();
}
  1. Выше приведен мой код селена.
  2. Когда я выполняю свой файл набора с параллельными = "методами"and thread count =" 3 ", я получаю следующую ошибку:" com.relevantcodes.extentreports.ExtentTestInterruptedException: Close был вызван до того, как тест мог благополучно завершиться с использованием EndTest. ".
  3. Во время отладки я обнаружил, что еще до того, как все endTest () в AfterMehtod были запущены, вызывался AfterSuite.
  4. Я пробовал разные варианты, такие как код, например, удаление статических,вызов метода endTest () в самом тесте, а не после метода, удаление вызова close () из AfterSuite и многих других вариантов.Но все равно получаю ту же ошибку.
  5. Я перепробовал все возможные решения, приведенные в интернете, но безрезультатно.

...