提交 661891cc authored 作者: mry's avatar mry

fix(base): 修改了swaggerController中的一些bug,以及报告模板格式

上级 f529be99
...@@ -6,7 +6,6 @@ import freemarker.template.TemplateExceptionHandler; ...@@ -6,7 +6,6 @@ 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.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;
...@@ -38,12 +37,10 @@ public class GenerateReporter { ...@@ -38,12 +37,10 @@ public class GenerateReporter {
Map context = new HashMap(); Map context = new HashMap();
ReporterData reporterData = new ReporterData(); ReporterData reporterData = new ReporterData();
DataBean dataBean = reporterData.testDataBean(); DataBean dataBean = reporterData.testDataBean();
DataMove dataMove = reporterData.testDataBeanMove();
List<DataBeans> dataBeansList = reporterData.testDataBeans(); List<DataBeans> dataBeansList = reporterData.testDataBeans();
// 这里是公共的信息. // 这里是公共的信息.
for (DataBeans bean : dataBeansList) { for (DataBeans bean : dataBeansList) {
context.put("overView", dataBean); context.put("overView", dataBean);
context.put("move", dataMove);
if (bean.getResult()) { if (bean.getResult()) {
context.put("pass", dataBeansList); context.put("pass", dataBeansList);
} else { } else {
......
...@@ -6,14 +6,11 @@ import freemarker.template.TemplateExceptionHandler; ...@@ -6,14 +6,11 @@ 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.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;
...@@ -40,12 +37,10 @@ public class GenerateReporterJob { ...@@ -40,12 +37,10 @@ public class GenerateReporterJob {
Map context = new HashMap(); Map context = new HashMap();
ReporterDataJob reporterDatajob = new ReporterDataJob(); ReporterDataJob reporterDatajob = new ReporterDataJob();
DataBean dataBean = reporterDatajob.testDataBean(); DataBean dataBean = reporterDatajob.testDataBean();
// List<DataMove> dataMoves = reporterDatajob.testDataBeanMove();
List<DataBeans> dataBeansList = reporterDatajob.testDataBeans(); List<DataBeans> dataBeansList = reporterDatajob.testDataBeans();
// 这里是公共的信息. // 这里是公共的信息.
for (DataBeans bean : dataBeansList) { for (DataBeans bean : dataBeansList) {
context.put("overView", dataBean); context.put("overView", dataBean);
// context.put("move", dataMoves);
if (bean.getResult()) { if (bean.getResult()) {
context.put("pass", dataBeansList); context.put("pass", dataBeansList);
} else { } else {
......
package org.matrix.testNg.web.report; package org.matrix.testNg.web.report;
import org.matrix.testNg.utils.Duration;
import org.matrix.testNg.utils.SecToTime;
import org.matrix.testNg.web.entity.DataBean; import org.matrix.testNg.web.entity.DataBean;
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.DataMove;
import org.matrix.testNg.web.vo.DataBeansVo;
import org.matrix.util.ReporterUtils; import org.matrix.util.ReporterUtils;
import java.util.List; import java.util.List;
...@@ -21,37 +18,7 @@ public class ReporterData { ...@@ -21,37 +18,7 @@ public class ReporterData {
* @return 补全了的所有报告信息 * @return 补全了的所有报告信息
*/ */
public DataBean testDataBean() { public DataBean testDataBean() {
DataBeansVo dataBeansVo = ReporterUtils.map.get("dataBeansVo"); return ReporterUtils.map.get("dataBeansVo").getDataBean();
// int passNum = 0;
// int failNum = 0;
// Long oneTime = 0L;
// 测试结果汇总数据
DataBean dataBean = dataBeansVo.getDataBean();
// List<DataBeans> dataBeanLists = dataBeansVo.getDataBeanLists();
// for (DataBeans dataBeanList : dataBeanLists) {
// Long duration = dataBeanList.getDuration();
// oneTime = oneTime + duration;
// if (dataBeanList.getResult()) {
// passNum += 1;
// } else {
// failNum += 1;
// }
// }
// //成功
// dataBean.setPassNum(passNum);
// //失败
// dataBean.setFailNum(failNum);
// //总数
// dataBean.setTotal(passNum + failNum);
// //通过率
// dataBean.setProbability(passNum / (passNum + failNum));
// Duration duration = SecToTime.secToTime(oneTime);
// Integer hour = duration.getHour();
// Integer minute = duration.getMinute();
// Integer second = duration.getSecond();
// String allTime = hour + "." + minute + "." + second;
// dataBean.setAllTime(allTime);
return dataBean;
} }
/** /**
......
package org.matrix.testNg.web.report; package org.matrix.testNg.web.report;
import org.matrix.testNg.utils.Duration;
import org.matrix.testNg.utils.SecToTime;
import org.matrix.testNg.web.entity.DataBean; import org.matrix.testNg.web.entity.DataBean;
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.DataMove;
import org.matrix.testNg.web.vo.DataBeansJobVo;
import org.matrix.testNg.web.vo.DataBeansMoveVo; import org.matrix.testNg.web.vo.DataBeansMoveVo;
import org.matrix.util.ReporterUtils; import org.matrix.util.ReporterUtils;
...@@ -22,40 +19,7 @@ public class ReporterDataJob { ...@@ -22,40 +19,7 @@ public class ReporterDataJob {
* @return 补全了的所有报告信息 * @return 补全了的所有报告信息
*/ */
public DataBean testDataBean() { public DataBean testDataBean() {
DataBeansJobVo dataBeansJobVo = ReporterUtils.jobMap.get("job"); return ReporterUtils.jobMap.get("job").getDataBean();
// int passNum = 0;
// int failNum = 0;
// Long oneTime = 0L;
// 测试结果汇总数据
DataBean dataBean = dataBeansJobVo.getDataBean();
// List<DataBeansMoveVo> dataBeansMoveVos = dataBeansJobVo.getDataBeansMove();
// for (DataBeansMoveVo dataBeansMoveVo : dataBeansMoveVos) {
// List<DataBeans> dataBeansList = dataBeansMoveVo.getDataBeansList();
// for (DataBeans dataBeans : dataBeansList) {
// Long duration = dataBeans.getDuration();
// oneTime = oneTime + duration;
// if (dataBeans.getResult()) {
// passNum += 1;
// } else {
// failNum += 1;
// }
// }
// }
// //成功
// dataBean.setPassNum(passNum);
// //失败
// dataBean.setFailNum(failNum);
// //总数
// dataBean.setTotal(passNum + failNum);
// //通过率
// dataBean.setProbability(passNum / (passNum + failNum));
// Duration duration = SecToTime.secToTime(oneTime);
// Integer hour = duration.getHour();
// Integer minute = duration.getMinute();
// Integer second = duration.getSecond();
// String allTime = hour + "." + minute + "." + second;
// dataBean.setAllTime(allTime);
return dataBean;
} }
/** /**
...@@ -63,11 +27,11 @@ public class ReporterDataJob { ...@@ -63,11 +27,11 @@ public class ReporterDataJob {
*/ */
public List<DataMove> testDataBeanMove() { public List<DataMove> testDataBeanMove() {
List<DataMove> dataMoveList = new ArrayList<>(); List<DataMove> dataMoveList = new ArrayList<>();
// List<DataBeansMoveVo> dataBeansMoveVos = ReporterUtils.jobMap.get("job").getDataBeansMove(); List<DataBeansMoveVo> dataBeansMoveVos = ReporterUtils.jobMap.get("job").getDataBeansMove();
// for (DataBeansMoveVo dataBeansMoveVo : dataBeansMoveVos) { for (DataBeansMoveVo dataBeansMoveVo : dataBeansMoveVos) {
// DataMove dataMove = dataBeansMoveVo.getDataMove(); DataMove dataMove = dataBeansMoveVo.getDataMove();
// dataMoveList.add(dataMove); dataMoveList.add(dataMove);
// } }
return dataMoveList; return dataMoveList;
} }
......
...@@ -19,26 +19,49 @@ ...@@ -19,26 +19,49 @@
<div class="topForm"> <div class="topForm">
<div class="topTitle">报告汇总</div> <div class="topTitle">报告汇总</div>
<form class="form"> <form class="form">
<#if overView ??>
<div class="form-group flex"> <div class="form-group flex">
<label for="exampleInputEmail1">用例总数:</label> <label for="total">用例总数:</label>
<span class="form-control" id="total">${overView.total!}</span> <input class="form-control" id="total" readonly="readonly" value="${overView.total!}"/>
</div> </div>
<div class="form-group flex"> <div class="form-group flex">
<label for="exampleInputPassword1">执行时间(s):</label> <label for="allTime">执行时间(s):</label>
<span class="form-control" id="allTime">${overView.allTime!}</span> <input class="form-control" id="allTime" readonly="readonly" value="${overView.allTime!}"/>
</div> </div>
<div class="form-group flex"> <div class="form-group flex">
<label for="exampleInputPassword1">通过:</label> <label for="passNum">通过:</label>
<span class="form-control" id="passNum">${overView.passNum!}</span> <input class="form-control" id="passNum" readonly="readonly" value="${overView.passNum!}"/>
</div> </div>
<div class="form-group flex"> <div class="form-group flex">
<label for="exampleInputPassword1">失败:</label> <label for="failNum">失败:</label>
<span class="form-control" id="failNum">${overView.failNum!}</span> <input class="form-control" id="failNum" readonly="readonly" value="${overView.failNum!}"/>
</div> </div>
<div class="form-group flex"> <div class="form-group flex">
<label for="exampleInputPassword1">测试通过率:</label> <label for="probability">测试通过率:</label>
<span class="form-control" id="probability">${overView.probability!}</span> <input class="form-control" id="probability" readonly="readonly" value="${overView.probability!}"/>
</div> </div>
<#else>
<div class="form-group flex">
<label for="total">用例总数:</label>
<input class="form-control" id="total" readonly="readonly" value="0"/>
</div>
<div class="form-group flex">
<label for="allTime">执行时间(s):</label>
<input class="form-control" id="allTime" readonly="readonly" value="0"/>
</div>
<div class="form-group flex">
<label for="passNum">通过:</label>
<input class="form-control" id="passNum" readonly="readonly" value="0"/>
</div>
<div class="form-group flex">
<label for="failNum">失败:</label>
<input class="form-control" id="failNum" readonly="readonly" value="0"/>
</div>
<div class="form-group flex">
<label for="probability">测试通过率:</label>
<input class="form-control" id="probability" readonly="readonly" value="0"/>
</div>
</#if>
</form> </form>
</div> </div>
<div class="table"> <div class="table">
......
...@@ -62,7 +62,7 @@ public class SwaggerController { ...@@ -62,7 +62,7 @@ public class SwaggerController {
} }
reader.close(); reader.close();
} catch (IOException e) { } catch (IOException e) {
throw new GlobalException("请求swagger数据失败"); throw new GlobalException(String.format("请求swagger数据失败,您读的swagger地址ip为 %d", url));
} }
return json.toString(); return json.toString();
} }
......
...@@ -12,7 +12,7 @@ public class PageTools { ...@@ -12,7 +12,7 @@ public class PageTools {
//总共多少条数据 //总共多少条数据
long total = results.getTotal(); long total = results.getTotal();
//页数 //页数
long length = total / pageSize; long length = total / pageSize + 1;
if (total % pageSize != 0) { if (total % pageSize != 0) {
length = length + 1; length = length + 1;
} }
......
...@@ -20,24 +20,24 @@ ...@@ -20,24 +20,24 @@
<div class="topTitle">报告汇总</div> <div class="topTitle">报告汇总</div>
<form class="form"> <form class="form">
<div class="form-group flex"> <div class="form-group flex">
<label for="exampleInputEmail1">用例总数:</label> <label for="total">用例总数:</label>
<input type="email" class="form-control" id="exampleInputEmail1" placeholder="Email"> <input type="text" class="form-control" id="total" readonly="readonly" value="total"/>
</div> </div>
<div class="form-group flex"> <div class="form-group flex">
<label for="exampleInputPassword1">执行时间(s):</label> <label for="allTime">执行时间(s):</label>
<input type="password" class="form-control" id="exampleInputPassword1" placeholder="Password"> <input type="text" class="form-control" id="allTime" readonly="readonly" value="allTime"/>
</div> </div>
<div class="form-group flex"> <div class="form-group flex">
<label for="exampleInputPassword1">通过:</label> <label for="passNum">通过:</label>
<input type="password" class="form-control" id="exampleInputPassword1" placeholder="Password"> <input type="text" class="form-control" id="passNum" readonly="readonly" value="passNum"/>
</div> </div>
<div class="form-group flex"> <div class="form-group flex">
<label for="exampleInputPassword1">失败:</label> <label for="failNum">失败:</label>
<input type="password" class="form-control" id="exampleInputPassword1" placeholder="Password"> <input type="text" class="form-control" id="failNum" readonly="readonly" value="failNum"/>
</div> </div>
<div class="form-group flex"> <div class="form-group flex">
<label for="exampleInputPassword1">测试通过率:</label> <label for="probability">测试通过率:</label>
<input type="password" class="form-control" id="exampleInputPassword1" placeholder="Password"> <input type="text" class="form-control" id="probability" readonly="readonly" value="probability"/>
</div> </div>
</form> </form>
</div> </div>
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论