提交 140784c0 authored 作者: mry's avatar mry

fix(base): 生成简陋报告,完成了基本功能

上级 efbe03c3
...@@ -5,29 +5,28 @@ import freemarker.template.Template; ...@@ -5,29 +5,28 @@ import freemarker.template.Template;
import freemarker.template.TemplateExceptionHandler; import freemarker.template.TemplateExceptionHandler;
import org.matrix.exception.GlobalException; import org.matrix.exception.GlobalException;
import org.matrix.testNg.web.entity.DataBean; import org.matrix.testNg.web.entity.DataBean;
import org.matrix.testNg.web.entity.DataMove;
import org.matrix.testNg.web.entity.DataBeans; import org.matrix.testNg.web.entity.DataBeans;
import org.matrix.testNg.web.entity.DataMove;
import org.matrix.testNg.web.entity.ReportMessage; import org.matrix.testNg.web.entity.ReportMessage;
import org.matrix.util.ReporterUtils; import org.matrix.util.ReporterUtils;
import java.io.*; import java.io.*;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.UUID;
/** /**
* @author mruny * @author mruny
*/ */
public class GenerateReporter { public class GenerateReporter {
private static final LocalDateTime TIME = LocalDateTime.now(); private static final String OUTPUT_FOLDER = System.getProperty("user.dir") + "/htmls";
private static final DateTimeFormatter DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd-HH-mm-ss"); private static final String FILE_NAME = UUID.randomUUID().toString().replace("-", "") + ".html";
private static final String STRING = DATE_TIME_FORMATTER.format(TIME);
private static final String OUTPUT_FOLDER = System.getProperty("user.dir") + "/"; FileOutputStream out;
private static final String FILE_NAME = STRING + "-testNg.html"; Writer writer;
public ReportMessage generateReport() { public ReportMessage generateReport() {
try { try {
...@@ -35,7 +34,7 @@ public class GenerateReporter { ...@@ -35,7 +34,7 @@ public class GenerateReporter {
cfg.setClassForTemplateLoading(this.getClass(), "/templates"); cfg.setClassForTemplateLoading(this.getClass(), "/templates");
cfg.setDefaultEncoding("UTF-8"); cfg.setDefaultEncoding("UTF-8");
cfg.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER); cfg.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
Template temp = cfg.getTemplate("overview.ftl"); Template temp = cfg.getTemplate("overviewBeautiful.ftl");
Map context = new HashMap(); Map context = new HashMap();
ReporterData reporterData = new ReporterData(); ReporterData reporterData = new ReporterData();
DataBean dataBean = reporterData.testDataBean(); DataBean dataBean = reporterData.testDataBean();
...@@ -57,17 +56,27 @@ public class GenerateReporter { ...@@ -57,17 +56,27 @@ public class GenerateReporter {
reportDir.mkdir(); reportDir.mkdir();
} }
// 输出流 // 输出流
FileOutputStream out = new FileOutputStream(OUTPUT_FOLDER + "/" + FILE_NAME); out = new FileOutputStream(OUTPUT_FOLDER + "/" + FILE_NAME);
Writer writer = new BufferedWriter(new OutputStreamWriter(out, StandardCharsets.UTF_8)); writer = new BufferedWriter(new OutputStreamWriter(out, StandardCharsets.UTF_8));
// 转换输出 // 转换输出
temp.process(context, writer); temp.process(context, writer);
writer.flush(); writer.flush();
ReportMessage reportMessage = new ReportMessage(); ReportMessage reportMessage = new ReportMessage();
reportMessage.setUrl(OUTPUT_FOLDER + "/" + FILE_NAME); reportMessage.setUrl("/report/" + FILE_NAME);
return reportMessage; return reportMessage;
} catch (Exception e) { } catch (Exception e) {
throw new GlobalException(e.getMessage()); throw new GlobalException(e.getMessage());
} finally { } finally {
try {
out.close();
} catch (IOException e) {
e.printStackTrace();
}
try {
writer.close();
} catch (IOException e) {
e.printStackTrace();
}
ReporterUtils.map = new HashMap<>(); ReporterUtils.map = new HashMap<>();
} }
} }
......
...@@ -17,17 +17,18 @@ import java.time.format.DateTimeFormatter; ...@@ -17,17 +17,18 @@ import java.time.format.DateTimeFormatter;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.UUID;
/** /**
* @author MRY * @author MRY
*/ */
public class GenerateReporterJob { public class GenerateReporterJob {
private static final LocalDateTime TIME = LocalDateTime.now(); private static final String OUTPUT_FOLDER = System.getProperty("user.dir") + "/htmls";
private static final DateTimeFormatter DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd-HH-mm-ss"); private static final String FILE_NAME = UUID.randomUUID().toString().replace("-", "") + ".html";
private static final String STRING = DATE_TIME_FORMATTER.format(TIME);
private static final String OUTPUT_FOLDER = System.getProperty("user.dir") + "/"; FileOutputStream out;
private static final String FILE_NAME = STRING + "-testNg.html"; Writer writer;
public ReportMessage generateReport() { public ReportMessage generateReport() {
try { try {
...@@ -35,7 +36,7 @@ public class GenerateReporterJob { ...@@ -35,7 +36,7 @@ public class GenerateReporterJob {
cfg.setClassForTemplateLoading(this.getClass(), "/templates"); cfg.setClassForTemplateLoading(this.getClass(), "/templates");
cfg.setDefaultEncoding("UTF-8"); cfg.setDefaultEncoding("UTF-8");
cfg.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER); cfg.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
Template temp = cfg.getTemplate("overviews.ftl"); Template temp = cfg.getTemplate("overviewBeautifuls.ftl");
Map context = new HashMap(); Map context = new HashMap();
ReporterDataJob reporterDatajob = new ReporterDataJob(); ReporterDataJob reporterDatajob = new ReporterDataJob();
DataBean dataBean = reporterDatajob.testDataBean(); DataBean dataBean = reporterDatajob.testDataBean();
...@@ -57,17 +58,27 @@ public class GenerateReporterJob { ...@@ -57,17 +58,27 @@ public class GenerateReporterJob {
reportDir.mkdir(); reportDir.mkdir();
} }
// 输出流 // 输出流
FileOutputStream out = new FileOutputStream(OUTPUT_FOLDER + "/" + FILE_NAME); out = new FileOutputStream(OUTPUT_FOLDER + "/" + FILE_NAME);
Writer writer = new BufferedWriter(new OutputStreamWriter(out, StandardCharsets.UTF_8)); writer = new BufferedWriter(new OutputStreamWriter(out, StandardCharsets.UTF_8));
// 转换输出 // 转换输出
temp.process(context, writer); temp.process(context, writer);
writer.flush(); writer.flush();
ReportMessage reportMessage = new ReportMessage(); ReportMessage reportMessage = new ReportMessage();
reportMessage.setUrl(OUTPUT_FOLDER + "/" + FILE_NAME); reportMessage.setUrl("/report/" + FILE_NAME);
return reportMessage; return reportMessage;
} catch (Exception e) { } catch (Exception e) {
throw new GlobalException(e.getMessage()); throw new GlobalException(e.getMessage());
} finally { } finally {
try {
out.close();
} catch (IOException e) {
e.printStackTrace();
}
try {
writer.close();
} catch (IOException e) {
e.printStackTrace();
}
ReporterUtils.jobMap = new HashMap<>(); ReporterUtils.jobMap = new HashMap<>();
} }
} }
......
...@@ -70,8 +70,8 @@ public class GenerateReporter implements IReporter { ...@@ -70,8 +70,8 @@ public class GenerateReporter implements IReporter {
} catch (Exception e) { } catch (Exception e) {
throw new GlobalException(e.getMessage()); throw new GlobalException(e.getMessage());
} finally { } finally {
ReporterUtils.resultMap = new HashMap<>(); // ReporterUtils.resultMap = new HashMap<>();
ReporterUtils.userResultMap = new HashMap<>(); // ReporterUtils.userResultMap = new HashMap<>();
} }
} }
} }
\ No newline at end of file
...@@ -68,39 +68,39 @@ public class ReporterData { ...@@ -68,39 +68,39 @@ public class ReporterData {
DataBean data = new DataBean(); DataBean data = new DataBean();
// 测试结果详细数据 // 测试结果详细数据
List<DataBean> list = new ArrayList<DataBean>(); List<DataBean> list = new ArrayList<DataBean>();
//工具类 // //工具类
ReportUnits units = new ReportUnits(); // ReportUnits units = new ReportUnits();
for (ITestResult result : sortByTime(map.getAllResults())) { // for (ITestResult result : sortByTime(map.getAllResults())) {
List<TestDataExecuteResult> testDataExecuteResults; // List<TestDataExecuteResult> testDataExecuteResults;
Map<Long, List<TestDataExecuteResult>> longListMap = ReporterUtils.userResultMap.get(1L); // Map<Long, List<TestDataExecuteResult>> longListMap = ReporterUtils.userResultMap.get(1L);
Set<Long> longs = longListMap.keySet(); // Set<Long> longs = longListMap.keySet();
for (Long caseId : longs) { // for (Long caseId : longs) {
TestCase testCase = java.util.Optional.of(testCaseService.getById(caseId)) // TestCase testCase = java.util.Optional.of(testCaseService.getById(caseId))
.orElseThrow(() -> new GlobalException(String.format("没有找到id = %d 的TestCase", caseId))); // .orElseThrow(() -> new GlobalException(String.format("没有找到id = %d 的TestCase", caseId)));
testDataExecuteResults = ReporterUtils.resultMap.get(caseId); // testDataExecuteResults = ReporterUtils.resultMap.get(caseId);
for (TestDataExecuteResult testDataExecuteResult : testDataExecuteResults) { // for (TestDataExecuteResult testDataExecuteResult : testDataExecuteResults) {
data.setDuration(units.formatDuration(result.getEndMillis() // data.setDuration(units.formatDuration(result.getEndMillis()
- result.getStartMillis())); // - result.getStartMillis()));
data.setParams(units.getParams(result)); // data.setParams(units.getParams(result));
CheckPointResult checkPointResult = testDataExecuteResult.getCheckPointResult(); // CheckPointResult checkPointResult = testDataExecuteResult.getCheckPointResult();
data.setTestCaseName(testCase.getName()); // data.setTestCaseName(testCase.getName());
data.setOutput(Reporter.getOutput(result)); // data.setOutput(Reporter.getOutput(result));
data.setDependMethod(units.getDependMethods(result)); // data.setDependMethod(units.getDependMethods(result));
data.setType(String.valueOf(testCase.getType())); // data.setType(String.valueOf(testCase.getType()));
data.setDetail(testCase.getDetail()); // data.setDetail(testCase.getDetail());
data.setMoveBefore(testCase.getMoveBefore()); // data.setMoveBefore(testCase.getMoveBefore());
data.setMoveAfterCase(testCase.getMoveAfterCase()); // data.setMoveAfterCase(testCase.getMoveAfterCase());
data.setMoveAfterTest(testCase.getMoveAfterTest()); // data.setMoveAfterTest(testCase.getMoveAfterTest());
data.setDescription(testCase.getDes()); // data.setDescription(testCase.getDes());
data.setResultMessage(checkPointResult); // data.setResultMessage(checkPointResult);
data.setThrowable(result.getThrowable()); // data.setThrowable(result.getThrowable());
if (result.getThrowable() != null) { // if (result.getThrowable() != null) {
data.setStackTrace(result.getThrowable().getStackTrace()); // data.setStackTrace(result.getThrowable().getStackTrace());
} // }
} // }
} // }
list.add(data); // list.add(data);
} // }
return list; return list;
} }
} }
\ No newline at end of file
package org.matrix.util; package org.matrix.util;
import org.matrix.actuators.usecase.TestCaseExecuteResult; //import org.matrix.actuators.usecase.TestCaseExecuteResult;
import org.matrix.testNg.web.vo.DataBeansJobVo; import org.matrix.testNg.web.vo.DataBeansJobVo;
import org.matrix.testNg.web.vo.DataBeansVo; import org.matrix.testNg.web.vo.DataBeansVo;
...@@ -13,9 +13,9 @@ import java.util.Map; ...@@ -13,9 +13,9 @@ import java.util.Map;
*/ */
public class ReporterUtils { public class ReporterUtils {
public static Map<Long, Map<Long, List<TestCaseExecuteResult>>> userResultMap = new HashMap<>(); // public static Map<Long, Map<Long, List<TestCaseExecuteResult>>> userResultMap = new HashMap<>();
public static Map<Long, List<TestCaseExecuteResult>> resultMap = new HashMap<>(); // public static Map<Long, List<TestCaseExecuteResult>> resultMap = new HashMap<>();
public static Map<String, DataBeansVo> map = new HashMap<>(); public static Map<String, DataBeansVo> map = new HashMap<>();
......
<?xml version="1.0" encoding="utf-8" ?>
<head>
<title>test</title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
<meta name="description" content="TestNG unit test results."/>
<style type="text/css">
body {
margin: 10px 20px;
font-size: 14px;
font-family: "Arial", "Microsoft YaHei", "黑体", "宋体", sans-serif;
}
.successBtn {
width: 60px;
padding: 3px;
background-color: #58ab48;
border-color: #58ab48;
color: #fff;
-moz-border-radius: 10px;
-webkit-border-radius: 10px;
border-radius: 10px;
-khtml-border-radius: 10px;
text-align: center;
vertical-align: middle;
border: 1px solid transparent;
font-weight: 500;
}
.failBtn {
width: 60px;
padding: 3px;
background-color: #ab2e2d;
border-color: #ab2e2d;
color: #fff;
-moz-border-radius: 10px;
-webkit-border-radius: 10px;
border-radius: 10px; /* future proofing */
-khtml-border-radius: 10px; /* for old Konqueror browsers */
text-align: center;
vertical-align: middle;
border: 1px solid transparent;
font-weight: 500;
}
</style>
<style>
/* Border styles */
.tabNoBorder thead, .tabNoBorder tr {
border-top-width: 1px;
border-top-style: solid;
border-top-color: rgb(211, 202, 221);
}
.tabNoBorder {
border-bottom-width: 1px;
border-bottom-style: solid;
border-bottom-color: rgb(211, 202, 221);
}
/* Padding and font style */
.tabNoBorder td, .tabNoBorder th {
padding: 5px 10px;
font-size: 14px;
font-family: Verdana;
color: rgb(95, 74, 121);
}
/* Alternating background colors */
.tabNoBorder tr:nth-child(even) {
background: rgb(223, 216, 232)
}
.tabNoBorder tr:nth-child(odd) {
background: #FFF
}
</style>
</head>
<body>
<br/>
<h2>Summary</h2>
<table id="summary" class="tabNoBorder">
<tr class="columnHeadings">
<th>用例总数</th>
<th>执行通过</th>
<th>执行失败</th>
<th>执行时间(s)</th>
<th>用例通过率</th>
</tr>
<tr>
<td>${overView.total}</td><#--用例总数-->
<td>${overView.passNum}</td><#--执行通过-->
<td>${overView.failNum}</td><#--执行失败-->
<td>${overView.allTime}</td><#--执行时间(s)-->
<td>${overView.probability}</td><#--用例通过率-->
</tr>
</table>
<br/><br/>
<table id="moveAction" class="tabNoBorder">
<tr class="columnHeadings">
<th>前置动作</th>
<th>中置动作</th>
<th>后置动作</th>
</tr>
<tr>
<td>${move.moveBefore}</td><#--用例总数-->
<td>${move.moveAfterCase}</td><#--未执行用例数-->
<td>${move.moveAfterTest}</td><#--执行通过-->
</tr>
</table>
<br/><br/>
<h2>Detail</h2>
<table class="tabNoBorder">
<tr class="columnHeadings">
<th>编号</th>
<th>用例名称</th>
<th>用例类型</th>
<th>详细参数</th>
<th>用例描述</th>
<th>执行结果</th>
<th>执行时间(s)</th>
<th>结果信息</th>
</tr>
<#assign caseNo = 0>
<#list fail as failCase>
<tr>
<#assign caseNo=caseNo+1>
<td>${caseNo}</td><#--编号-->
<td>${failCase.testCaseName!}</td><#--用例名称-->
<td>${failCase.type!}</td><#--用例类型-->
<td>${failCase.detail!}</td><#--详细参数-->
<td>${failCase.description!}</td><#--用例描述-->
<td>${failCase.result}</td>
<td>${failCase.duration!}</td><#--<th>执行时间(s)</th>-->
<td>${failCase.resultMessage!}</td>
</tr>
</#list>
<#list pass as passCase>
<tr>
<#assign caseNo=caseNo+1>
<td>${caseNo}</td><#--编号-->
<td>${passCase.testCaseName!}</td><#--用例名称-->
<td>${passCase.type!}</td><#--用例类型-->
<td>${passCase.detail!}</td><#--详细参数-->
<td>${passCase.moveBefore!}</td><#--前置动作-->
<td>${passCase.moveAfterCase!}</td><#--中间动作-->
<td>${passCase.moveAfterTest!}</td><#--后置动作-->
<td>${passCase.description}</td><#--用例描述-->
<td>${passCase.result}</td>
<td>${passCase.duration!}</td><#--执行时间(s)-->
<td>${passCase.resultMessage!}</td><#--结果信息-->
</tr>
</#list>
</table>
</body>
</html>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8" ?>
<head>
<title>test</title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
<meta name="description" content="TestNG unit test results."/>
<style type="text/css">
body {
margin: 10px 20px;
font-size: 14px;
font-family: "Arial", "Microsoft YaHei", "黑体", "宋体", sans-serif;
}
.successBtn {
width: 60px;
padding: 3px;
background-color: #58ab48;
border-color: #58ab48;
color: #fff;
-moz-border-radius: 10px;
-webkit-border-radius: 10px;
border-radius: 10px;
-khtml-border-radius: 10px;
text-align: center;
vertical-align: middle;
border: 1px solid transparent;
font-weight: 500;
}
.failBtn {
width: 60px;
padding: 3px;
background-color: #ab2e2d;
border-color: #ab2e2d;
color: #fff;
-moz-border-radius: 10px;
-webkit-border-radius: 10px;
border-radius: 10px; /* future proofing */
-khtml-border-radius: 10px; /* for old Konqueror browsers */
text-align: center;
vertical-align: middle;
border: 1px solid transparent;
font-weight: 500;
}
</style>
<style>
/* Border styles */
.tabNoBorder thead, .tabNoBorder tr {
border-top-width: 1px;
border-top-style: solid;
border-top-color: rgb(211, 202, 221);
}
.tabNoBorder {
border-bottom-width: 1px;
border-bottom-style: solid;
border-bottom-color: rgb(211, 202, 221);
}
/* Padding and font style */
.tabNoBorder td, .tabNoBorder th {
padding: 5px 10px;
font-size: 14px;
font-family: Verdana;
color: rgb(95, 74, 121);
}
/* Alternating background colors */
.tabNoBorder tr:nth-child(even) {
background: rgb(223, 216, 232)
}
.tabNoBorder tr:nth-child(odd) {
background: #FFF
}
</style>
</head>
<body>
<br/>
<h2>Summary</h2>
<table id="summary" class="tabNoBorder">
<tr class="columnHeadings">
<th>用例总数</th>
<th>执行通过</th>
<th>执行失败</th>
<th>执行时间(s)</th>
<th>用例通过率</th>
</tr>
<tr>
<td>${overView.total!}</td><#--用例总数-->
<td>${overView.passNum!}</td><#--执行通过-->
<td>${overView.failNum!}</td><#--执行失败-->
<td>${overView.allTime!}</td><#--执行时间(s)-->
<td>${overView.probability!}</td><#--用例通过率-->
</tr>
</table>
<br/><br/>
<h2>Move</h2>
<table id="move" class="tabNoBorder">
<tr class="columnHeadings">
<th>前置动作</th>
<th>中置动作</th>
<th>后置动作</th>
</tr>
<tr>
<td>${move.moveBefore!无}</td><#--用例总数-->
<td>${move.moveAfterCase!无}</td><#--未执行用例数-->
<td>${move.moveAfterTest!无}</td><#--执行通过-->
</tr>
</table>
<br/><br/>
<h2>Detail</h2>
<table class="tabNoBorder">
<tr class="columnHeadings">
<th>编号</th>
<th>用例名称</th>
<th>用例类型</th>
<th>详细参数</th>
<th>用例描述</th>
<th>执行结果</th>
<th>执行时间(s)</th>
<th>结果信息</th>
</tr>
<#assign caseNo = 0>
<#if fail ??>
<#list fail as failCase>
<tr>
<#assign caseNo=caseNo+1>
<td>${caseNo}</td><#--编号-->
<td>${failCase.testCaseName!'无'}</td><#--用例名称-->
<td>${failCase.type!'无'}</td><#--用例类型-->
<td>${failCase.detail!'无'}</td><#--详细参数-->
<td>${failCase.description!'无'}</td><#--用例描述-->
<td>${failCase.result?c}</td>
<td>${failCase.duration!'无'}</td><#--<th>执行时间(s)</th>-->
<td>${failCase.resultMessage!'无'}</td>
</tr>
</#list>
<#else>
</#if>
<#if pass ??>
<#list pass as passCase>
<tr>
<#assign caseNo=caseNo+1>
<td>${caseNo}</td><#--编号-->
<td>${passCase.testCaseName!"无"}</td><#--用例名称-->
<td>${passCase.type!'无'}</td><#--用例类型-->
<td>${passCase.detail!'无'}</td><#--详细参数-->
<td>${passCase.description!'无'}</td><#--用例描述-->
<td>${passCase.result?c}</td>
<td>${passCase.duration!'无'}</td><#--执行时间(s)-->
<td>${passCase.resultMessage!'无'}</td><#--结果信息-->
</tr>
</#list>
<#else>
</#if>
</table>
</body>
</html>
\ No newline at end of file
...@@ -8,6 +8,64 @@ ...@@ -8,6 +8,64 @@
<link href="https://cdn.bootcss.com/animate.css/3.5.2/animate.min.css" rel="stylesheet"> <link href="https://cdn.bootcss.com/animate.css/3.5.2/animate.min.css" rel="stylesheet">
<link href="https://cdn.bootcss.com/chosen/1.8.2/chosen.css" rel="stylesheet"> <link href="https://cdn.bootcss.com/chosen/1.8.2/chosen.css" rel="stylesheet">
<base target="_blank"> <base target="_blank">
<style>
.black_overlay {
display: none;
position: absolute;
top: 0%;
left: 0%;
width: 100%;
height: 100%;
background-color: black;
z-index: 1001;
-moz-opacity: 0.8;
opacity: .80;
filter: alpha(opacity=88);
}
.white_content {
display: none;
position: absolute;
top: 25%;
left: 25%;
width: 55%;
height: 55%;
padding: 20px;
border: 10px solid orange;
background-color: white;
z-index: 1002;
overflow: auto;
}
</style>
<style>
.black_overlay {
display: none;
position: absolute;
top: 0%;
left: 0%;
width: 100%;
height: 100%;
background-color: black;
z-index: 1001;
-moz-opacity: 0.8;
opacity: .80;
filter: alpha(opacity=88);
}
.white_content {
display: none;
position: absolute;
top: 25%;
left: 25%;
width: 55%;
height: 55%;
padding: 20px;
border: 10px solid orange;
background-color: white;
z-index: 1002;
overflow: auto;
}
</style>
<style type="text/css"> <style type="text/css">
h1, h2, h3, h4, h5, h6 { h1, h2, h3, h4, h5, h6 {
font-weight: 100 font-weight: 100
...@@ -7028,74 +7086,64 @@ ...@@ -7028,74 +7086,64 @@
</div> </div>
<div class="wrapper wrapper-content animated fadeInRight"> <div class="wrapper wrapper-content animated fadeInRight">
<div class="row"> <div class="row">
<div class="col-sm-12"> <div class="col-sm-12" style="height: 270px;">
<div class="ibox float-e-margins"> <div class="ibox float-e-margins">
<div class="ibox-title"> <div class="ibox-title">
<h5>报告汇总</h5> <h5>报告汇总</h5>
<!-- <div class="ibox-tools">-->
<!-- <a class="collapse-link">-->
<!-- <i class="fa fa-chevron-up"></i>-->
<!-- </a>-->
<!-- <a class="close-link">-->
<!-- <i class="fa fa-times"></i>-->
<!-- </a>-->
<!-- </div>-->
</div> </div>
<div class="ibox-content" style="width: 100%;"> <div class="ibox-content" style="width: 100%;">
<div class="row"> <div class="row">
<div class="col-sm-6 b-r" style="height:350px;width: 50%;"> <div class="col-sm-6 b-r" style="height:350px;width: 50%;">
<form class="form-horizontal" style="width: 100%;"> <form class="form-horizontal" style="width: 100%;">
<div class="form-group" style="width: 100%;"> <div class="form-group" style="width: 100%;">
<label class="col-sm-2 control-label text-navy" style="width: 15%;">用例总数:</label> <label class="col-sm-2 control-label text-navy"
<div class="col-sm-5" style="width: 15%;"> style="width: 15%;">用例总数:</label>
<span class="form-control" id="testPass"><td>${overView.allTestsSize}</td></span><#--用例总数--> <div class="col-sm-5" style="width: 20%;">
<span class="form-control" id="testName">${overView.total!}</span>
</div>
<label class="col-sm-2 control-label text-navy"
style="width: 15%;">执行时间(s):</label>
<div class="col-sm-5" style="width: 20%;">
<span class="form-control" id="allTime">${overView.allTime!}</span>
</div> </div>
</div> </div>
<div class="form-group" style="width: 100%;"> <div class="form-group" style="width: 100%;">
<label class="col-sm-2 control-label text-navy" style="width: 15%;">通过:</label> <label class="col-sm-2 control-label text-navy" style="width: 15%;">通过:</label>
<div class="col-sm-5" style="width: 20%;"> <div class="col-sm-5" style="width: 20%;">
<span class="form-control" id="totalTime"><td>${overView.passedTestsSize}</td></span><#--执行通过--> <span class="form-control" id="passNum">${overView.passNum!}</span>
</div>
<label class="col-sm-2 control-label text-warning" style="width: 15%;">跳过:</label>
<div class="col-sm-5" style="width: 15%;">
<span class="form-control text-warning" id="testSkip"><td>${overView.skippedTestsSize}</td></span><#--跳过用例数-->
</div> </div>
<label class="col-sm-2 control-label text-danger" style="width: 15%;">失败:</label> <label class="col-sm-2 control-label text-danger"
style="width: 15%;">失败:</label>
<div class="col-sm-5" style="width: 20%;"> <div class="col-sm-5" style="width: 20%;">
<span class="form-control text-danger" id="testFail"><td>${overView.failedTestsSize}</td></span><#--执行失败--> <span class="form-control text-danger" id="failNum">${overView.failNum!}</span>
</div> </div>
</div> </div>
<div class="form-group" style="width: 100%;"> <div class="form-group" style="width: 100%;">
<label class="col-sm-2 control-label text-navy" style="width: 15%;">未执行:</label> <label class="col-sm-2 control-label text-navy"
style="width: 15%;">测试通过率:</label>
<div class="col-sm-5" style="width: 20%;"> <div class="col-sm-5" style="width: 20%;">
<span class="form-control" id="query_total_count"><td>${overView.excludeTestsSize}</td></span><#--未执行用例数--> <span class="form-control" id="probability">${overView.probability!}</span>
</div> </div>
</div> </div>
<div class="form-group" style="width: 100%;">
<label class="col-sm-2 control-label text-navy" style="width: 15%;">执行时间(s):</label>
<label text-warning style="width: 85%;" id="testVersion">
<td>${overView.testsTime}</td>
</label><#--执行时间(s)-->
</div>
<div class="form-group" style="width: 100%;">
<label class="col-sm-2 control-label text-navy" style="width: 15%;">用例通过率:</label>
<label text-warning style="width: 85%;" id="testAPI">
<td>${overView.passPercent}</td>
</label><#--用例通过率-->
</div>
</form> </form>
</div> </div>
<div class="col-sm-6 b-r"> <div class="col-sm-6 b-r" style="margin: 10px 0">
<div class="mt-tabpage-title"> <label class="col-sm-2 control-label text-navy" style="width: 15%;">前置动作:</label>
<a href="javascript:;" class="mt-tabpage-item" id="click_button">用例数量统计图</a> <div class="col-sm-5" style="width: 70%;">
<a href="javascript:;" class="mt-tabpage-item mt-tabpage-item-cur" id="click_button2">用例结果统计图</a> <span class="form-control" id="moveBefore">${move.moveBefore!}</span>
<a href="javascript:;" class="mt-tabpage-item" id="click_button3">失败原因分类统计图</a> </div>
</div>
<div class="col-sm-6 b-r" style="margin: 10px 0">
<label class="col-sm-2 control-label text-navy" style="width: 15%;">后置动作:</label>
<div class="col-sm-5" style="width: 70%;">
<span class="form-control" id="moveAfterCase">${move.moveAfterCase!}</span>
</div>
</div>
<div class="col-sm-6 b-r" style="margin: 10px 0">
<label class="col-sm-2 control-label text-navy" style="width: 15%;">执行后行动:</label>
<div class="col-sm-5" style="width: 70%;">
<span class="form-control" id="moveAfterTest">${move.moveAfterTest!}</span>
</div> </div>
<br/>
<br/>
<div style="height:350px;display:none;" id="echarts-map-chart"></div>
<div style="height:350px;width:50%;display:block;" id="echarts-map-chart2"></div>
<div style="height:350px;width:50%;display:none;" id="echarts-map-chart3"></div>
</div> </div>
</div> </div>
</div> </div>
...@@ -7109,62 +7157,78 @@ ...@@ -7109,62 +7157,78 @@
<div class="row"> <div class="row">
<div class="col-sm-12"> <div class="col-sm-12">
<div class="ibox float-e-margins"> <div class="ibox float-e-margins">
<div class="ibox-title">
<h5>详细数据</h5>
</div>
<table class="table table-bordered"> <table class="table table-bordered">
<thead> <thead>
<tr style="width:100%;"> <tr style="width:100%;">
<th style="width:4%;">编号</th> <th style="width:5%;">编号</th>
<th style="width:6%;">用例名称</th> <th style="width:10%;">用例名称</th>
<th style="width:6%;">用例类型</th> <th style="width:5%;">用例类型</th>
<th style="width:9%;">详细参数</th> <th style="width:10%;">详细参数</th>
<th style="width:9%;">前置动作</th> <th style="width:20%;">用例描述</th>
<th style="width:9%;">中置动作</th> <th style="width:5%;">执行结果</th>
<th style="width:9%;">后置动作</th> <th style="width:15%;">执行时间</th>
<th style="width:9%;">用例描述</th> <th style="width:30%;">结果信息</th>
<th style="width:15%;">执行结果</th>
<th style="width:6%;">执行时间(s)</th>
<th style="width:15%;">执行结果</th>
</tr> </tr>
</thead>
<#assign caseNo = 0> <#assign caseNo = 0>
<#list fail as failCase> <#if fail ??>
<tr> <#list fail as failCase>
<#assign caseNo=caseNo+1> <tr>
<td>${caseNo}</td><#--编号--> <#assign caseNo=caseNo+1>
<td>${failCase.testCaseName!}</td><#--用例名称--> <th style="width:5%;">${caseNo}</th><#--编号-->
<td>${failCase.type!}</td><#--用例类型--> <th style="width:10%;">${failCase.testCaseName!}</th><#--用例名称-->
<td>${failCase.detail!}</td><#--详细参数--> <th style="width:5%;">${failCase.type!}</th><#--用例类型-->
<td>${failCase.moveBefore!}</td><#--前置动作--> <th style="width:10%;">${failCase.detail!}</th><#--详细参数-->
<td>${failCase.moveAfterCase!}</td><#--中间动作--> <th style="width:20%;">${failCase.description!}</th><#--用例描述-->
<td>${failCase.moveAfterTest!}</td><#--后置动作--> <th style="width:5%;">${failCase.result?c}</th>
<td>${failCase.description!}</td><#--用例描述--> <th style="width:15%;">${failCase.duration!}</th><#--<th>执行时间(s)</th>-->
<td>${failCase.result}</td><#--是否成功--> <th style="width:30%;">
<td>${failCase.duration!}</td><#--<th>执行时间(s)</th>--> <span cla style="color: #1E0FBE" href="javascript:void(0)" onclick="
<td> document.getElementById('light').style.display='block';
${failCase.throwable!} document.getElementById('fade').style.display='block'">
</br> <#--<th>结果信息</th>-->
${failCase.resultMessage!} ${failCase.resultMessage!}
</td> </span>
</tr> </th>
</#list> <div id="light" class="white_content">
<#list pass as passCase> ${failCase.resultMessage!}
<tr> <button onclick="document.getElementById('light').style.display='none';
<#assign caseNo=caseNo+1> document.getElementById('fade').style.display='none'">btn
<td>${caseNo}</td><#--编号--> </button>
<td>${passCase.testCaseName!}</td><#--用例名称--> </div>
<td>${passCase.type!}</td><#--用例类型--> <div id="fade" class="black_overlay"></div>
<td>${passCase.detail!}</td><#--详细参数--> </tr>
<td>${passCase.moveBefore!}</td><#--前置动作--> </#list>
<td>${passCase.moveAfterCase!}</td><#--中间动作--> <#else>
<td>${passCase.moveAfterTest!}</td><#--后置动作--> </#if>
<td>${passCase.description}</td><#--用例描述--> <#if pass ??>
<td>${passCase.result}</td><#--是否成功--> <#list pass as passCase>
<td>${passCase.duration!}</td><#--执行时间(s)--> <tr>
<td>${passCase.resultMessage!}</td><#--结果信息--> <#assign caseNo=caseNo+1>
</tr> <th style="width:5%;">${caseNo}</th><#--编号-->
</#list> <th style="width:10%;">${passCase.testCaseName!}</th><#--用例名称-->
<th style="width:5%;">${passCase.type!}</th><#--用例类型-->
<th style="width:10%;">${passCase.detail!}</th><#--详细参数-->
<th style="width:20%;">${passCase.description!}</th><#--用例描述-->
<th style="width:5%;">${passCase.result?c}</th>
<th style="width:15%;">${passCase.duration!}</th><#--执行时间(s)-->
<th style="width:30%;">
<span cla style="color: #1E0FBE" href="javascript:void(0)" onclick="
document.getElementById('light').style.display='block';
document.getElementById('fade').style.display='block'">
${passCase.resultMessage!}
</span>
</th>
<div id="light" class="white_content">
${passCase.resultMessage!}
<button onclick="document.getElementById('light').style.display='none';
document.getElementById('fade').style.display='none'">关闭
</button>
</div>
<div id="fade" class="black_overlay"></div>
</tr>
</#list>
<#else>
</#if>
</thead>
<tbody id="detailBody"> <tbody id="detailBody">
</tbody> </tbody>
</table> </table>
...@@ -7180,7 +7244,8 @@ ...@@ -7180,7 +7244,8 @@
<script src="https://cdn.bootcss.com/echarts/3.8.5/echarts.min.js"></script> <script src="https://cdn.bootcss.com/echarts/3.8.5/echarts.min.js"></script>
<script src="https://cdn.bootcss.com/chosen/1.8.2/chosen.jquery.js"></script> <script src="https://cdn.bootcss.com/chosen/1.8.2/chosen.jquery.js"></script>
<script type="text/javascript"> <script type="text/javascript">
// var resultData = ${resultData}; <#--// var resultData = ${resultData};-->
function details(obj) { function details(obj) {
if ($(obj).text() == '展开') { if ($(obj).text() == '展开') {
......
This source diff could not be displayed because it is too large. You can view the blob instead.
<?xml version="1.0" encoding="utf-8" ?>
<head>
<title>test</title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
<meta name="description" content="TestNG unit test results."/>
<style type="text/css">
body {
margin: 10px 20px;
font-size: 14px;
font-family: "Arial", "Microsoft YaHei", "黑体", "宋体", sans-serif;
}
.successBtn {
width: 60px;
padding: 3px;
background-color: #58ab48;
border-color: #58ab48;
color: #fff;
-moz-border-radius: 10px;
-webkit-border-radius: 10px;
border-radius: 10px;
-khtml-border-radius: 10px;
text-align: center;
vertical-align: middle;
border: 1px solid transparent;
font-weight: 500;
}
.failBtn {
width: 60px;
padding: 3px;
background-color: #ab2e2d;
border-color: #ab2e2d;
color: #fff;
-moz-border-radius: 10px;
-webkit-border-radius: 10px;
border-radius: 10px; /* future proofing */
-khtml-border-radius: 10px; /* for old Konqueror browsers */
text-align: center;
vertical-align: middle;
border: 1px solid transparent;
font-weight: 500;
}
</style>
<style>
/* Border styles */
.tabNoBorder thead, .tabNoBorder tr {
border-top-width: 1px;
border-top-style: solid;
border-top-color: rgb(211, 202, 221);
}
.tabNoBorder {
border-bottom-width: 1px;
border-bottom-style: solid;
border-bottom-color: rgb(211, 202, 221);
}
/* Padding and font style */
.tabNoBorder td, .tabNoBorder th {
padding: 5px 10px;
font-size: 14px;
font-family: Verdana;
color: rgb(95, 74, 121);
}
/* Alternating background colors */
.tabNoBorder tr:nth-child(even) {
background: rgb(223, 216, 232)
}
.tabNoBorder tr:nth-child(odd) {
background: #FFF
}
</style>
</head>
<body>
<br/>
<h2>Summary</h2>
<table id="summary" class="tabNoBorder">
<tr class="columnHeadings">
<th>用例总数</th>
<th>执行通过</th>
<th>执行失败</th>
<th>执行时间(s)</th>
<th>用例通过率</th>
</tr>
<tr>
<td>${overView.total!}</td><#--用例总数-->
<td>${overView.passNum!}</td><#--执行通过-->
<td>${overView.failNum!}</td><#--执行失败-->
<td>${overView.allTime!}</td><#--执行时间(s)-->
<td>${overView.probability!}</td><#--用例通过率-->
</tr>
</table>
<br/><br/>
<table id="Move" class="tabNoBorder">
<h2>Move</h2>
<table id="move" class="tabNoBorder">
<#list move as moveCase>
<tr class="columnHeadings">
<th>前置动作</th>
<th>中置动作</th>
<th>后置动作</th>
</tr>
<tr>
<td>${moveCase.moveBefore!}</td><#--用例总数-->
<td>${moveCase.moveAfterCase!}</td><#--未执行用例数-->
<td>${moveCase.moveAfterTest!}</td><#--执行通过-->
</tr>
</table>
<table id="Detail" class="tabNoBorder">
<tr class="columnHeadings">
<th>编号</th>
<th>用例名称</th>
<th>用例类型</th>
<th>详细参数</th>
<th>用例描述</th>
<th>执行结果</th>
<th>执行时间(s)</th>
<th>结果信息</th>
</tr>
<#assign caseNo = 0>
<#if fail ??>
<#list fail as failCase>
<tr>
<#assign caseNo=caseNo+1>
<td>${caseNo}</td><#--编号-->
<td>${failCase.testCaseName!}</td><#--用例名称-->
<td>${failCase.type!}</td><#--用例类型-->
<td>${failCase.detail!}</td><#--详细参数-->
<td>${failCase.description!}</td><#--用例描述-->
<td>${failCase.result?c}</td>
<td>${failCase.duration!}</td><#--<th>执行时间(s)</th>-->
<td>${failCase.resultMessage!}</td>
</tr>
</#list>
<#else >
</#if>
<#if pass??>
<#list pass as passCase>
<tr>
<#assign caseNo=caseNo+1>
<td>${caseNo}</td><#--编号-->
<td>${passCase.testCaseName!}</td><#--用例名称-->
<td>${passCase.type!}</td><#--用例类型-->
<td>${passCase.detail!}</td><#--详细参数-->
<td>${passCase.description!}</td><#--用例描述-->
<td>${passCase.result?c}</td>
<td>${passCase.duration!}</td><#--执行时间(s)-->
<td>${passCase.resultMessage!}</td><#--结果信息-->
</tr>
</#list>
<#else >
</#if>
</#list>
</table>
</table>
</body>
</html>
\ No newline at end of file
...@@ -41,6 +41,13 @@ ...@@ -41,6 +41,13 @@
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<!-- https://mvnrepository.com/artifact/org.webjars.bower/jquery -->
<dependency>
<groupId>org.webjars.bower</groupId>
<artifactId>jquery</artifactId>
<version>3.6.0</version>
</dependency>
</dependencies> </dependencies>
</project> </project>
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论