Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 当我们使用TestNG并行执行运行脚本时,无法正确生成数据块报告输出。(数据块报告版本3.1) public类ExtentReports\u Basecode{ 静态随机兰德=新随机(); 静态长距离=(长距离)(rand.nextDouble()*1000000000L); 公共网络驱动程序; 公共静态扩展TMLReporter htmlReporter; 公共静态扩展范围; 公共静态延伸试验; 私有静态字符串filePath=“D://”+drand+“ExtentReports\u Bindu.html”; @套房前 公共作废设置(){ htmlReporter=新的ExtentHtmlReporter(文件路径); 区段=新的扩展端口(); extent.attachReporter(htmlReporter); 范围。设置系统信息(“OS”、“Windows10”); extent.setSystemInfo(“主机名”、“Bindu”); 范围。设置系统信息(“环境”、“玫瑰”); extent.setSystemInfo(“用户名”、“1234_-ws”); //htmlReporter.config().setChartVisibilityOnOpen(true); htmlReporter.config().setDocumentTitle(“演示报告中的AutomationTesting.in”); htmlReporter.config().setReportName(“最喜欢的自动化报告”); htmlReporter.config().setTheme(Theme.DARK); } @预处理法 公共无效开始测试(方法m) { test=extent.createTest(m.getName(),“这是测试的描述”+m.getName()); } @后置法 公共静态void getResult(ITestResult结果){ if(result.getStatus()==ITestResult.FAILURE){ test.log(Status.FAIL,markuplper.createLabel(result.getName()+“测试用例失败,原因是以下问题:”,extntColor.RED)); test.fail(result.getThrowable()); } 如果(result.getStatus()==ITestResult.SUCCESS){ log(Status.PASS,markupulper.createLabel(result.getName()+“测试用例通过”,ExtentColor.GREEN)); } 否则{ log(Status.SKIP,markupulper.createLabel(result.getName()+“已跳过测试用例”,ExtentColor.YELLOW)); test.skip(result.getThrowable()); } } @事后 公共无效拆卸(){ expndure.flush(); } }_Java_Selenium_Testng_Report_Extent - Fatal编程技术网

Java 当我们使用TestNG并行执行运行脚本时,无法正确生成数据块报告输出。(数据块报告版本3.1) public类ExtentReports\u Basecode{ 静态随机兰德=新随机(); 静态长距离=(长距离)(rand.nextDouble()*1000000000L); 公共网络驱动程序; 公共静态扩展TMLReporter htmlReporter; 公共静态扩展范围; 公共静态延伸试验; 私有静态字符串filePath=“D://”+drand+“ExtentReports\u Bindu.html”; @套房前 公共作废设置(){ htmlReporter=新的ExtentHtmlReporter(文件路径); 区段=新的扩展端口(); extent.attachReporter(htmlReporter); 范围。设置系统信息(“OS”、“Windows10”); extent.setSystemInfo(“主机名”、“Bindu”); 范围。设置系统信息(“环境”、“玫瑰”); extent.setSystemInfo(“用户名”、“1234_-ws”); //htmlReporter.config().setChartVisibilityOnOpen(true); htmlReporter.config().setDocumentTitle(“演示报告中的AutomationTesting.in”); htmlReporter.config().setReportName(“最喜欢的自动化报告”); htmlReporter.config().setTheme(Theme.DARK); } @预处理法 公共无效开始测试(方法m) { test=extent.createTest(m.getName(),“这是测试的描述”+m.getName()); } @后置法 公共静态void getResult(ITestResult结果){ if(result.getStatus()==ITestResult.FAILURE){ test.log(Status.FAIL,markuplper.createLabel(result.getName()+“测试用例失败,原因是以下问题:”,extntColor.RED)); test.fail(result.getThrowable()); } 如果(result.getStatus()==ITestResult.SUCCESS){ log(Status.PASS,markupulper.createLabel(result.getName()+“测试用例通过”,ExtentColor.GREEN)); } 否则{ log(Status.SKIP,markupulper.createLabel(result.getName()+“已跳过测试用例”,ExtentColor.YELLOW)); test.skip(result.getThrowable()); } } @事后 公共无效拆卸(){ expndure.flush(); } }

Java 当我们使用TestNG并行执行运行脚本时,无法正确生成数据块报告输出。(数据块报告版本3.1) public类ExtentReports\u Basecode{ 静态随机兰德=新随机(); 静态长距离=(长距离)(rand.nextDouble()*1000000000L); 公共网络驱动程序; 公共静态扩展TMLReporter htmlReporter; 公共静态扩展范围; 公共静态延伸试验; 私有静态字符串filePath=“D://”+drand+“ExtentReports\u Bindu.html”; @套房前 公共作废设置(){ htmlReporter=新的ExtentHtmlReporter(文件路径); 区段=新的扩展端口(); extent.attachReporter(htmlReporter); 范围。设置系统信息(“OS”、“Windows10”); extent.setSystemInfo(“主机名”、“Bindu”); 范围。设置系统信息(“环境”、“玫瑰”); extent.setSystemInfo(“用户名”、“1234_-ws”); //htmlReporter.config().setChartVisibilityOnOpen(true); htmlReporter.config().setDocumentTitle(“演示报告中的AutomationTesting.in”); htmlReporter.config().setReportName(“最喜欢的自动化报告”); htmlReporter.config().setTheme(Theme.DARK); } @预处理法 公共无效开始测试(方法m) { test=extent.createTest(m.getName(),“这是测试的描述”+m.getName()); } @后置法 公共静态void getResult(ITestResult结果){ if(result.getStatus()==ITestResult.FAILURE){ test.log(Status.FAIL,markuplper.createLabel(result.getName()+“测试用例失败,原因是以下问题:”,extntColor.RED)); test.fail(result.getThrowable()); } 如果(result.getStatus()==ITestResult.SUCCESS){ log(Status.PASS,markupulper.createLabel(result.getName()+“测试用例通过”,ExtentColor.GREEN)); } 否则{ log(Status.SKIP,markupulper.createLabel(result.getName()+“已跳过测试用例”,ExtentColor.YELLOW)); test.skip(result.getThrowable()); } } @事后 公共无效拆卸(){ expndure.flush(); } },java,selenium,testng,report,extent,Java,Selenium,Testng,Report,Extent,脚本1: 公共类sc1扩展了扩展端口\u Basecode{ 公共网络驱动程序; 公共报告=空; 字符串inputSheetPath=“TestData/InputData/DataSheet.xls”; @试验前 公共void启动浏览器(){ System.out.println(“启动Chrome浏览器”); dr=Driver.getChromeDriver(); } @试验 私人无效sc1_95_Fav(){ System.out.println(“sc1”);} } } 脚本2: 公共

脚本1:

公共类sc1扩展了扩展端口\u Basecode{
公共网络驱动程序;
公共报告=空;
字符串inputSheetPath=“TestData/InputData/DataSheet.xls”;
@试验前
公共void启动浏览器(){
System.out.println(“启动Chrome浏览器”);
dr=Driver.getChromeDriver();
}
@试验
私人无效sc1_95_Fav(){
System.out.println(“sc1”);}
}
}
脚本2:
公共类sc2扩展了ExtentReports\u基代码{
公共网络驱动程序;
公共报告=空;
字符串inputSheetPath=“TestData/InputData/DataSheet.xls”;
@试验前
公共void启动浏览器(){
System.out.println(“启动Chrome浏览器”);
dr=Driver.getChromeDriver();
}
@试验
私人无效sc2_83_Fav(){
}
}
}
TestNG XML:


在扩展报告中,我在第二个测试用例中得到了结果。。是否有人可以建议我遗漏了什么,以及如何使用扩展报告使用TestNG进行并行测试来正确查看输出。
PS:当我使用testNG一个接一个地顺序运行时,它工作正常。

遵循此模式,希望您的问题能够得到解决

WebDriver driver;
ExtentHtmlReporter htmlReporter;
ExtentReports extent;
ExtentTest test;



        @BeforeTest
        public void setUp() {
            // where we need to generate the report

            htmlReporter = new ExtentHtmlReporter("Your report Path");
            extent = new ExtentReports();
            extent.attachReporter(htmlReporter);
            // Set our document title, theme etc..
            htmlReporter.config().setDocumentTitle("Rehomes");
            htmlReporter.config().setReportName("Rehomes Production Testing");
            htmlReporter.config().setTestViewChartLocation(ChartLocation.TOP);
            htmlReporter.config().setTheme(Theme.DARK);


                        }
       }
        @Test
        public void HomepageLogo() throws Exception {
            test = extent.createTest("rentalhomesHomePage");
            //Your Test

        }

      @AfterMethod
      public void setTestResult(ITestResult result) throws IOException {


          if (result.getStatus() == ITestResult.FAILURE) {
              test.log(Status.FAIL, result.getName());
              test.log(Status.FAIL,result.getThrowable());
              //test.fail("Screen Shot : " + test.addScreenCaptureFromPath(screenShot));
          } else if (result.getStatus() == ITestResult.SUCCESS) {
              test.log(Status.PASS, result.getName());
              //test.pass("Screen Shot : " + test.addScreenCaptureFromPath(screenShot));
          } else if (result.getStatus() == ITestResult.SKIP) {
              test.skip("Test Case : " + result.getName() + " has been skipped");
          }

          extent.flush();
      driver.close();

        }
    }

感谢您的回复,但不幸的是,上述一个力的工作,并给出了只有一个测试生成的报告,如果以这种方式尝试。你能提出其他方法来解决这个问题吗?

请使用评论,不要发表评论作为答案