extentReport 生成测试报告

发表于:2017-8-16 11:45

字体: | 上一篇 | 下一篇 | 我要投稿

 作者:Lozz    来源:51Testing软件测试网采编

  之前在使用extentReport生成测试报告的时候,没有加载到相关的css,经检查为下面两个文件没有正确加载。
  后改变配置,加载本地的css和js文件,目前测试报告正确显示
  1.创建TestNg的Report监听器,实现方法:
  private void init() {
          // TODO Auto-generated method stub
          File reportDir = new File(OUTPUT_FOLDER);
          // 文件夹不存在的话进行创建
          if (!reportDir.exists() && !reportDir.isDirectory()) {
              reportDir.mkdir();
          }
          ExtentHtmlReporter htmlReporter = new ExtentHtmlReporter(OUTPUT_FOLDER + FILE_NAME);
          htmlReporter.config().setDocumentTitle(ReportUtil.getReportName());
          htmlReporter.config().setReportName(ReportUtil.getReportName());
          htmlReporter.config().setChartVisibilityOnOpen(true);
          htmlReporter.config().setTestViewChartLocation(ChartLocation.TOP);
          htmlReporter.config().setTheme(Theme.STANDARD);
          // 设置系统信息样式:.card-panel.environment th:first-child{ width:30%;}
          htmlReporter.config().setCSS(
                  ".node.level-1  ul{ display:none;} .node.level-1.active ul{display:block;}  .card-panel.environment  th:first-child{ width:30%;}");
          // 移除按键监听事件
          htmlReporter.config().setJS("$(window).off(\"keydown\");");
          // 设置静态文件的DNS
          // 如果cdn.rawgit.com访问不了,可以设置为:ResourceCDN.EXTENTREPORTS或者ResourceCDN.GITHUB
          htmlReporter.config().setResourceCDN(ResourceCDN.EXTENTREPORTS);
          extent = new ExtentReports();
          extent.attachReporter(htmlReporter);
          extent.setReportUsesManualConfiguration(true);
      }
《2023软件测试行业现状调查报告》独家发布~

关注51Testing

联系我们

快捷面板 站点地图 联系我们 广告服务 关于我们 站长统计 发展历程

法律顾问:上海兰迪律师事务所 项棋律师
版权所有 上海博为峰软件技术股份有限公司 Copyright©51testing.com 2003-2024
投诉及意见反馈:webmaster@51testing.com; 业务联系:service@51testing.com 021-64471599-8017

沪ICP备05003035号

沪公网安备 31010102002173号