Java 在数据块报告、日志和testng文件中面临问题
我正在开发一个同时需要两个浏览器的应用程序,所以我的代码同时启动两个浏览器Chrome和FF,在Chrome上执行一些测试用例,在FF上并行执行一些测试用例——当我通过执行文件执行我的代码时,它执行良好,并分别为所有套件生成扩展报告。现在,我正试图通过testng.xml(见下文)执行我的项目,它包含多个suit,我发现问题如下; 1.每个测试用例在日志下显示两次,但在数据块报告中显示一次 2.为两套西装生成一个范围报告,因为我想为每套西装生成一个报告 testng.xml 以下是数据块报告配置代码Java 在数据块报告、日志和testng文件中面临问题,java,selenium-webdriver,selenium-extent-report,testng.xml,Java,Selenium Webdriver,Selenium Extent Report,Testng.xml,我正在开发一个同时需要两个浏览器的应用程序,所以我的代码同时启动两个浏览器Chrome和FF,在Chrome上执行一些测试用例,在FF上并行执行一些测试用例——当我通过执行文件执行我的代码时,它执行良好,并分别为所有套件生成扩展报告。现在,我正试图通过testng.xml(见下文)执行我的项目,它包含多个suit,我发现问题如下; 1.每个测试用例在日志下显示两次,但在数据块报告中显示一次 2.为两套西装生成一个范围报告,因为我想为每套西装生成一个报告 testng.xml 以下是数据块报
public static void Property(String Suite, String RName) throws InterruptedException, AWTException, IOException{
try {
ExtentHtmlReporter htmlReporter;
htmlReporter = new ExtentHtmlReporter("./Reports/"+Suite);
extent = new ExtentReports();
extent.attachReporter(htmlReporter);
extent.setSystemInfo("HostName", "Iftikhar");
extent.setSystemInfo("Environment", "QA");
extent.setSystemInfo("UserName", "Muhammad Iftikhar");
extent.setSystemInfo("URL", envirnment);
// extent.setReportUsesManualConfiguration(true);
htmlReporter.config().setDocumentTitle("Automation Testing Report");
htmlReporter.config().setReportName("Sep Report");
htmlReporter.config().setTestViewChartLocation(ChartLocation.TOP);
htmlReporter.config().setTheme(Theme.DARK);
htmlReporter.getStartTime();
htmlReporter.getEndTime();
}
catch (IndexOutOfBoundsException e) {
System.err.println("IndexOutOfBoundsException: " + e.getMessage());
}
}
有关日志和数据块报告,请参见下面的屏幕截图
我在这个问题上工作了很多天,但仍然没有成功。向所有人请求帮助。多谢各位 问题解决了,问题解决了。
public void getResult(ITestResult result ) throws IOException, InterruptedException{
/*
System.out.println("Get Status "+ result.getStatus());
System.out.println("Get Method with className "+ result.getMethod());
System.out.println("Get TC Name "+ result.getName());
System.out.println("Get test calsss Name "+ result.getTestClass());
System.out.println("Get Test Name"+ result.getTestName());
System.out.println("Get Method Name"+ result.isSuccess());
*/
test = extent.createTest(result.getName());
if(result.getStatus()==ITestResult.SUCCESS){
test.log(Status.PASS, result.getMethod().getDescription());
test.log(Status.PASS, MarkupHelper.createLabel(result.getName() + " Test Case is Passed", ExtentColor.GREEN));
test.log(Status.PASS, " Please see attached screenshot");
String screenshotPath = HelpingFunction.capture(result.getName());
test.addScreenCaptureFromPath(screenshotPath);
extent.flush();
}
if(result.getStatus()==ITestResult.FAILURE){
test.log(Status.FAIL, MarkupHelper.createLabel(result.getName() + "Test Case is Failed due to Below Issue", ExtentColor.RED));
/*
* String screenshotPath = HelpingFunction.capture(result.getName());
* test.addScreenCaptureFromPath(screenshotPath);
*/
test.fail(result.getThrowable());
extent.flush();
}
if(result.getStatus()==ITestResult.SKIP){
System.out.print("Test cases is skipped");
test.log(Status.SKIP, MarkupHelper.createLabel(result.getName() + "Test Case is SKIPPED", ExtentColor.YELLOW));
test.skip(result.getThrowable());
}
}
@AfterTest
public void endReport(){
driver.close();
//extent.flush();
//driver.get(System.getProperty("user.dir")+"/Reports/"+Suite);
}
public static void Property(String Suite, String RName) throws InterruptedException, AWTException, IOException{
try {
ExtentHtmlReporter htmlReporter;
htmlReporter = new ExtentHtmlReporter("./Reports/"+Suite);
extent = new ExtentReports();
extent.attachReporter(htmlReporter);
extent.setSystemInfo("HostName", "Iftikhar");
extent.setSystemInfo("Environment", "QA");
extent.setSystemInfo("UserName", "Muhammad Iftikhar");
extent.setSystemInfo("URL", envirnment);
// extent.setReportUsesManualConfiguration(true);
htmlReporter.config().setDocumentTitle("Automation Testing Report");
htmlReporter.config().setReportName("Sep Report");
htmlReporter.config().setTestViewChartLocation(ChartLocation.TOP);
htmlReporter.config().setTheme(Theme.DARK);
htmlReporter.getStartTime();
htmlReporter.getEndTime();
}
catch (IndexOutOfBoundsException e) {
System.err.println("IndexOutOfBoundsException: " + e.getMessage());
}
}