extentReport生成測試報告


之前在使用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);
    }
View Code

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM