英文:
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<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();
}
}
While running you suite or .xml file, add the above class as listener.
<listeners>
<listener class-name="YOUR.LOCATION.ExtentReporter" />
</listeners>
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论