extentReport生成測試報告
阿新 • • 發佈:2017-08-08
方法 idt amp cnblogs tchart block none 目前 創建
之前在使用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 htmlReporterView Code= 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); }
extentReport生成測試報告