ztest 是一个测试报告,报告清晰简单,有饼图,汇总,运行详情。有兴趣的可以下载试用!
将报告的 json 数据替换 template 文件中的
${resultData}即可。
${resultData}。比如:Gson gson = new GsonBuilder().disableHtmlEscaping().create();
String template = FileUtil.read(templatePath);
template = template.replaceFirst("\\$\\{resultData\\}", gson.toJson(result));
output.write(template);
{
    "testPass": 1,
    "testResult": [
        {
            "className": "com.test.testcase.TestDemo1",
            "methodName": "testDemo",
            "description": "测试DEMO",
            "spendTime": "11ms",
            "status": "成功",
            "log": [
                "this is demo!"
            ]
        }
    ],
    "testName": "20171109132744897",
    "testAll": 1,
    "testFail": 0,
    "beginTime": "2017-11-09 13:27:44.917",
    "totalTime": "11ms",
    "testSkip": 0
}
请参考ztest中的TestDemo1.java ZTestReport.java

感谢 mock 哥提供的 python unittest 实现部分,使用 python unittest 的同学可以无缝对接该报告!
mock 哥 git 地址:mock 哥 git 地址
    
     