0
  1. 我正在使用 selenium 和 TestNG 在 java 中编写自动化测试用例。
  2. 我想使用 selenium 生成范围报告,我通过引用网站编写了一些代码。
  3. 在运行我的自动化测试用例时,我没有收到任何错误,但没有生成范围报告。

范围报告生成的示例代码:

@BeforeTest
    private void setup() throws Exception {
        ExtentHtmlReporter htmlReporter = new ExtentHtmlReporter(REPORTS_PATH + "/" + file_Prefix + "_extent.html");
        extent = new ExtentReports();
        htmlReporter.loadXMLConfig("src/test/resources/extent-config.xml");
        extent.attachReporter(htmlReporter);
        extent.setSystemInfo("Host Name", "SoftwareTestingMaterial");
        extent.setSystemInfo("Environment", "Automation Testing");

        htmlReporter.config().setDocumentTitle("Find Duplicates By Calculating Distance Between Lat/Long");
        htmlReporter.config().setReportName("Automation Report");
        htmlReporter.config().setTestViewChartLocation(ChartLocation.TOP);
        htmlReporter.config().setTheme(Theme.STANDARD);}

GetResult 方法和 End Report 方法的示例代码:

@AfterMethod
public void getResult(ITestResult result) {
    if (result.getStatus() == ITestResult.FAILURE) {
        // logger.log(Status.FAIL, "Test Case Failed is "+result.getTestName());
        // MarkupHelper is used to display the output in different colors
        extentTest.log(Status.FAIL,
                MarkupHelper.createLabel(result.getTestName() + " - Test Case Failed", ExtentColor.RED));
        extentTest.log(Status.FAIL,
                MarkupHelper.createLabel(result.getThrowable() + " - Test Case Failed", ExtentColor.RED));
    }
}

@AfterTest
public void endReport() {
    File duplicate_File = new File(REPORTS_PATH + "/" + file_Prefix + "_duplicates.csv");
    try {
        FileUtils.writeLines(duplicate_File, duplicate_Pois, false);
    } catch (IOException e) {
        LOG.error("Error writing to file " + e.getMessage());
    }
    extent.flush();
}
4

0 回答 0