一個(gè)易用的HTML測(cè)試報(bào)告模板

在我們的自動(dòng)化測(cè)試實(shí)施工作中,一個(gè)美觀易讀的測(cè)試報(bào)告是必不可少的一部分。而各大框架特別是一些單元測(cè)試框架如junit、maven test等生成的報(bào)告格式都不盡人意。 今天就向大家推薦一個(gè)簡(jiǎn)單易用的報(bào)告生成模板。
要使用它,只需要將模板文件template引入你的自動(dòng)化項(xiàng)目,將自動(dòng)化執(zhí)行結(jié)果的相關(guān)數(shù)據(jù)重寫(xiě)組合為一個(gè)json字串,然后替換模板文件中的${resultData}數(shù)據(jù),最后重寫(xiě)生成自己的html報(bào)告文件即可。

${resultData}數(shù)據(jù)如下

{
    "testPass": 3, 
    "testResult": [
        {
            "className": "com.test.testcase.TestDemo1",
            "methodName": "testDemo",
            "description": "測(cè)試DEMO",
            "spendTime": "11ms",
            "status": "成功",
            "log": [
                "this is demo!"
            ]
        },
        {
            "className": "com.test.testcase.TestDemo2",
            "methodName": "testDemo",
            "description": "測(cè)試DEMO",
            "spendTime": "11ms",
            "status": "成功",
            "log": [
                "this is demo!"
            ]
        },
        {
            "className": "com.test.testcase.TestDemo3",
            "methodName": "testDemo",
            "description": "測(cè)試DEMO",
            "spendTime": "11ms",
            "status": "失敗",
            "log": [
                "this is demo!"
            ]
        }
    ],
    "testName": "20171109132744897",
    "testAll": 3,
    "testFail": 1,
    "beginTime": "2017-11-09 13:27:44.917",
    "totalTime": "33ms",
    "testSkip": 0
}

生成的測(cè)試報(bào)告如圖


demo.png
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容