Can we integrate Extent reports with Qmetry Automation Framework(QAF)?

huangapple go评论79阅读模式
英文:

Can we integrate Extent reports with Qmetry Automation Framework(QAF)?

问题

我们能否将Extent报告(特别是使用适配器、TestNG或Cucumber)集成到Qmetry自动化框架(QAF)中?如果可以,请提供步骤。
从我的端来看,我尝试了这里提到的内容:http://extentreports.com/docs/versions/4/java/testng.html
但我没有看到生成任何报告。

英文:

Can we integrate Extent reports(specifically using Adapters, TestNG or Cucumber)with Qmetry Automation Framework(QAF)? If Yes, please provide the steps.
From my end, I tried what is mentioned here: http://extentreports.com/docs/versions/4/java/testng.html
And I am not seeing any reports being generated.

答案1

得分: 1

你的问题的答案是:是的。

在Qmetry Automation Framework(QAF)中,我们可以集成Extent报告。

我会在我的下一个更新中提供具体的操作步骤。

编辑/更新:
创建一个如下的类:

public class ExtentReporter implements IReporter {
    private ExtentReports extent;

    @Override
    public void generateReport(List<XmlSuite> xmlSuites, List<ISuite> suites, String outputDirectory) {
        extent = new ExtentReports(System.getProperty("user.dir") + "/ExtentReport.html", true);
        for (ISuite suite : suites) {
            Map<String, ISuiteResult> result = suite.getResults();

            for (ISuiteResult r : result.values()) {
                ITestContext context = r.getTestContext();
                try {
                    buildTestNodes(context.getPassedTests(), LogStatus.PASS);
                    buildTestNodes(context.getFailedTests(), LogStatus.FAIL);
                    buildTestNodes(context.getSkippedTests(), LogStatus.SKIP);
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }

        extent.flush();
        extent.close();
    }

    private void buildTestNodes(IResultMap tests, LogStatus status) throws IOException {
        ExtentTest test;

        if (tests.size() > 0) {
            for (ITestResult result : tests.getAllResults()) {
                test = extent.startTest(result.getMethod().getMethodName());

                test.getTest().setStartedTime(getTime(result.getStartMillis()));
                test.getTest().setEndedTime(getTime(result.getEndMillis()));

                for (String group : result.getMethod().getGroups())
                    test.assignCategory(group);

                String message = "Test " + status.toString().toLowerCase() + "ed";

                if (result.getThrowable() != null)
                    message = result.getThrowable().getMessage();

                test.log(status, message);
                extent.endTest(test);
            }
        }
    }

    private Date getTime(long millis) {
        Calendar calendar = Calendar.getInstance();
        calendar.setTimeInMillis(millis);
        return calendar.getTime();
    }
}

在运行测试套件或者 .xml 文件时,将上述类添加为监听器。

<listeners>
    <listener class-name="YOUR.LOCATION.ExtentReporter" />
</listeners>
英文:

Answer to your question is : YES.
In Qmetry Automation Framework(QAF) we can integrate Extent reports.

I'll provide the HOW TO steps in my next update.

Edit / Update:
Create a class as below:

public class ExtentReporter implements IReporter {
private ExtentReports extent;
@Override
public void generateReport(List&lt;XmlSuite&gt; xmlSuites, List&lt;ISuite&gt; suites, String outputDirectory) {
extent = new ExtentReports(System.getProperty(&quot;user.dir&quot;)+&quot;/ExtentReport.html&quot;, true);
for (ISuite suite : suites) {
Map&lt;String, ISuiteResult&gt; result = suite.getResults();
for (ISuiteResult r : result.values()) {
ITestContext context = r.getTestContext();
try {
buildTestNodes(context.getPassedTests(), LogStatus.PASS);
buildTestNodes(context.getFailedTests(), LogStatus.FAIL);
buildTestNodes(context.getSkippedTests(), LogStatus.SKIP);
} catch (IOException e) {
e.printStackTrace();
}
}
}
extent.flush();
extent.close();
}
private void buildTestNodes(IResultMap tests, LogStatus status) throws IOException {
ExtentTest test;
if (tests.size() &gt; 0) {
for (ITestResult result : tests.getAllResults()) {
test = extent.startTest(result.getMethod().getMethodName());
test.getTest().setStartedTime(getTime(result.getStartMillis()));
test.getTest().setEndedTime(getTime(result.getEndMillis()));
for (String group : result.getMethod().getGroups())
test.assignCategory(group);
String message = &quot;Test &quot; + status.toString().toLowerCase() + &quot;ed&quot;;
if (result.getThrowable() != null)
message = result.getThrowable().getMessage();
test.log(status, message);
extent.endTest(test);
}
}
}
private Date getTime(long millis) {
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(millis);
return calendar.getTime();
}

}

While running you suite or .xml file, add the above class as listener.

	&lt;listeners&gt;
&lt;listener class-name=&quot;YOUR.LOCATION.ExtentReporter&quot; /&gt;
&lt;/listeners&gt;

huangapple
  • 本文由 发表于 2020年5月29日 17:49:51
  • 转载请务必保留本文链接:https://go.coder-hub.com/62083148.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定