4Manuals

  • PDF Cloud HOME

为什么仅在范围报告中打印第二个测试套件? Download

    使用不同的定位器定位WebElement(NoSuchElementException) 无法在Mac终端中下载Android模拟器组件 如何使用Jest在React Native中测试Screenprops 我在硒中执行多个类,但无法在另一个类中找到驱动程序 如何使用适用于iOS的AWS设备场将警报自动接受设置为true / false? android应用程序自动化的最佳方法

我已经使用多个测试套件生成了范围报告。

但是它仅在范围报告中显示最后一个测试套件。

这是我的代码

@BeforeSuite
    public void beforeSuite() {

        htmlReporter = new ExtentHtmlReporter(Utils.getReportDir() + "/report.html");
        htmlReporter.loadXMLConfig(String.valueOf(new File("src/test/java/extentreports/extent-config.xml")));
        extent = new ExtentReports();
        extent.attachReporter(htmlReporter);

        extent.setSystemInfo("OS Name", System.getProperty("os.name"));
        extent.setSystemInfo("OS Version", System.getProperty("os.version"));
        extent.setSystemInfo("Java Version", System.getProperty("java.version"));
        extent.setSystemInfo("User Name", System.getProperty("user.name"));

        htmlReporter.config().setChartVisibilityOnOpen(true);
        htmlReporter.config().setDocumentTitle("Automation");
        htmlReporter.config().setReportName("Report");
        htmlReporter.config().setTestViewChartLocation(ChartLocation.TOP);
        htmlReporter.config().setTheme(Theme.DARK);

    }

 @AfterMethod
    public void getResult(ITestResult result) {
        if (result.getStatus() == ITestResult.FAILURE) {
            test.log(Status.FAIL, MarkupHelper.createLabel(result.getName() + " Test case FAILED due to below issues:", ExtentColor.RED));
            test.fail(result.getThrowable());
            String screenShotPath = MobileActions.Screenshot("Failed");

            try {
                test.addScreenCaptureFromPath(screenShotPath);
            } catch (IOException e) {
                e.printStackTrace();
            }
        } else if (result.getStatus() == ITestResult.SUCCESS) {
            test.log(Status.PASS, MarkupHelper.createLabel(result.getName() + " Test Case PASSED", ExtentColor.GREEN));
        } else {
            test.log(Status.SKIP, MarkupHelper.createLabel(result.getName() + " Test Case SKIPPED", ExtentColor.ORANGE));
            test.skip(result.getThrowable());
        }
    }



@AfterSuite
    public void flushReport() {
        extent.flush();
        loginAndroid.quitTest();
    }

要生成报告,我将以下代码用于每个测试用例。

test = extent.createTest("Add Image on Canvas");

和testng.xml如下。

 <suite-files>

        <suite-file path="Font_Module.xml"></suite-file>

        <suite-file path="Image_Module.xml"></suite-file>


    </suite-files>

它仅在范围报告中显示第二个套件结果。

建议我如何在范围报告中添加所有测试套件结果。

1 个答案:

答案 0 :(得分:1)

将您的@BeforeSuite更改为@BeforeTest并且
@AfterSuite至@AfterTest,它应该可以正常工作。



Similar searches
    需要帮助修复在Kali Linux上mysql安装中的错误 如何在Tkinter中使用PIL图像 无法在其他功能中使用功能 如何从Spring Boot调用python程序? 如何使用我的日期选择器的分割数据