用例执行新增用例会话sid
This commit is contained in:
@@ -44,4 +44,7 @@ public class TestCase extends BaseEntity
|
||||
|
||||
/** 删除标志(0代表存在 2代表删除) */
|
||||
private String delFlag;
|
||||
|
||||
/** 用例会话id */
|
||||
private String caseSid;
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ public class TestCaseLog extends BaseEntity
|
||||
|
||||
/** 用例id */
|
||||
@Excel(name = "用例id")
|
||||
private String caseId;
|
||||
private Long caseId;
|
||||
|
||||
/** 操作类别 */
|
||||
@Excel(name = "操作类别")
|
||||
@@ -45,4 +45,8 @@ public class TestCaseLog extends BaseEntity
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
@Excel(name = "操作时间", width = 30, dateFormat = "yyyy-MM-dd")
|
||||
private Date operTime;
|
||||
|
||||
/** 用例会话id */
|
||||
@Excel(name = "用例sid")
|
||||
private String caseSid;
|
||||
}
|
||||
|
||||
@@ -80,5 +80,9 @@ public class TestCaseResult extends BaseEntity {
|
||||
@Excel(name = "执行结果")
|
||||
private String status;
|
||||
|
||||
/** 用例会话id */
|
||||
@Excel(name = "用例sid")
|
||||
private String caseSid;
|
||||
|
||||
private String title;
|
||||
}
|
||||
|
||||
@@ -9,11 +9,10 @@ import com.test.common.utils.JMeterUtil;
|
||||
import com.test.common.utils.MySQLExecutor;
|
||||
import com.test.common.utils.StringUtils;
|
||||
import com.test.common.utils.sql.TinyIntTypeAdapter;
|
||||
import com.test.test.domain.TestCase;
|
||||
import com.test.test.domain.TestCaseResult;
|
||||
import com.test.test.domain.TestCaseStep;
|
||||
import com.test.test.domain.TestDatasource;
|
||||
import com.test.common.utils.uuid.IdUtils;
|
||||
import com.test.test.domain.*;
|
||||
import com.test.test.domain.qo.*;
|
||||
import com.test.test.mapper.TestCaseLogMapper;
|
||||
import com.test.test.mapper.TestCaseMapper;
|
||||
import com.test.test.mapper.TestCaseResultMapper;
|
||||
import com.test.test.mapper.TestDatasourceMapper;
|
||||
@@ -49,6 +48,8 @@ public class TestCaseServiceImpl implements ITestCaseService
|
||||
private TestCaseResultMapper testCaseResultMapper;
|
||||
@Resource
|
||||
private TestDatasourceMapper testDatasourceMapper;
|
||||
@Resource
|
||||
private TestCaseLogMapper testCaseLogMapper;
|
||||
|
||||
@Autowired
|
||||
private ITestCaseStepService testCaseStepService;
|
||||
@@ -140,12 +141,21 @@ public class TestCaseServiceImpl implements ITestCaseService
|
||||
log.error("用例计划已被删除,不能执行!");
|
||||
return false;
|
||||
}
|
||||
TestCaseLog testCaseLog = new TestCaseLog();
|
||||
testCaseLog.setCaseId(id);
|
||||
testCaseLog.setCreateTime(DateUtils.getNowDate());
|
||||
testCaseLog.setOperType("执行");
|
||||
String caseSid = IdUtils.simpleUUID();
|
||||
testCaseLog.setCaseSid(caseSid);
|
||||
testCase.setCaseSid(caseSid);
|
||||
List<TestCaseStep> testCaseStepList = testCaseStepService.selectTestCaseStepListByCaseId(id);
|
||||
for (TestCaseStep testCaseStep : testCaseStepList) {
|
||||
if (testCaseStep.getType() == 1L) {
|
||||
// http接口处理
|
||||
boolean httpTestResult = doHttpRequestTest(testCase, testCaseStep, jmeterHomePath);
|
||||
if (!httpTestResult) {
|
||||
testCaseLog.setOperDetail("失败");
|
||||
testCaseLogMapper.insertTestCaseLog(testCaseLog);
|
||||
log.error("用例步骤:{}执行失败!", testCaseStep.getName());
|
||||
return false;
|
||||
}
|
||||
@@ -153,6 +163,8 @@ public class TestCaseServiceImpl implements ITestCaseService
|
||||
// 数据库接口处理
|
||||
boolean dateSourceTestResult = doDateSourceRequestTest(testCase, testCaseStep);
|
||||
if (!dateSourceTestResult) {
|
||||
testCaseLog.setOperDetail("失败");
|
||||
testCaseLogMapper.insertTestCaseLog(testCaseLog);
|
||||
log.error("数据源用例步骤:{}执行失败!", testCaseStep.getName());
|
||||
return false;
|
||||
}
|
||||
@@ -160,6 +172,8 @@ public class TestCaseServiceImpl implements ITestCaseService
|
||||
// 循环节点处理
|
||||
boolean pollTestResult = doPollRequestTest(testCase, testCaseStep, jmeterHomePath);
|
||||
if (!pollTestResult) {
|
||||
testCaseLog.setOperDetail("失败");
|
||||
testCaseLogMapper.insertTestCaseLog(testCaseLog);
|
||||
log.error("循环用例步骤:{}执行失败!", testCaseStep.getName());
|
||||
return false;
|
||||
}
|
||||
@@ -167,6 +181,8 @@ public class TestCaseServiceImpl implements ITestCaseService
|
||||
// 轮询节点处理
|
||||
boolean loopTestResult = doLoopRequestTest(testCase, testCaseStep, jmeterHomePath);
|
||||
if (!loopTestResult) {
|
||||
testCaseLog.setOperDetail("失败");
|
||||
testCaseLogMapper.insertTestCaseLog(testCaseLog);
|
||||
log.error("轮询用例步骤:{}执行失败!", testCaseStep.getName());
|
||||
return false;
|
||||
}
|
||||
@@ -174,6 +190,8 @@ public class TestCaseServiceImpl implements ITestCaseService
|
||||
log.error("错误的用例步骤类型!");
|
||||
}
|
||||
}
|
||||
testCaseLog.setOperDetail("成功");
|
||||
testCaseLogMapper.insertTestCaseLog(testCaseLog);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -193,6 +211,7 @@ public class TestCaseServiceImpl implements ITestCaseService
|
||||
Map<String, String> resultMap = testCaseStepService.executeJmeterTestCaseStepById(testCaseStep.getId(), jmeterHomePath);
|
||||
testCaseResult.setCaseId(testCase.getId());
|
||||
testCaseResult.setStepId(testCaseStep.getId());
|
||||
testCaseResult.setCaseSid(testCase.getCaseSid());
|
||||
if (resultMap != null) {
|
||||
testCaseResult.setRequestHeader(resultMap.get("requestHeader"));
|
||||
testCaseResult.setRequestBody(resultMap.get("requestBody"));
|
||||
@@ -250,6 +269,7 @@ public class TestCaseServiceImpl implements ITestCaseService
|
||||
testCaseResult.setExecuteTime(DateUtils.getNowDate());
|
||||
testCaseResult.setCaseId(testCase.getId());
|
||||
testCaseResult.setStepId(testCaseStep.getId());
|
||||
testCaseResult.setCaseSid(testCase.getCaseSid());
|
||||
Long startTime = System.currentTimeMillis();
|
||||
TestDatasource testDatasource = testDatasourceMapper.selectTestDatasourceById(testCaseStep.getDatasourceId());
|
||||
Long useTime = System.currentTimeMillis() - startTime;
|
||||
@@ -319,6 +339,7 @@ public class TestCaseServiceImpl implements ITestCaseService
|
||||
testCaseResult.setExecuteTime(DateUtils.getNowDate());
|
||||
testCaseResult.setCaseId(testCase.getId());
|
||||
testCaseResult.setStepId(testCaseStep.getId());
|
||||
testCaseResult.setCaseSid(testCase.getCaseSid());
|
||||
Long parentId = testCaseStep.getId();
|
||||
TestCaseStep testCaseStepInput = new TestCaseStep();
|
||||
testCaseStepInput.setCaseId(testCase.getId());
|
||||
@@ -388,6 +409,7 @@ public class TestCaseServiceImpl implements ITestCaseService
|
||||
testCaseResult.setExecuteTime(DateUtils.getNowDate());
|
||||
testCaseResult.setCaseId(testCase.getId());
|
||||
testCaseResult.setStepId(testCaseStep.getId());
|
||||
testCaseResult.setCaseSid(testCase.getCaseSid());
|
||||
Long parentId = testCaseStep.getId();
|
||||
TestCaseStep testCaseStepInput = new TestCaseStep();
|
||||
testCaseStepInput.setCaseId(testCase.getId());
|
||||
|
||||
@@ -11,21 +11,23 @@
|
||||
<result property="operDetail" column="oper_detail"/>
|
||||
<result property="operUser" column="oper_user"/>
|
||||
<result property="operTime" column="oper_time"/>
|
||||
<result property="caseSid" column="case_sid"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectTestCaseLogVo">
|
||||
select id, case_id, oper_type, oper_detail, oper_user, oper_time
|
||||
select id, case_id, oper_type, oper_detail, oper_user, oper_time, case_sid
|
||||
from test_case_log
|
||||
</sql>
|
||||
|
||||
<select id="selectTestCaseLogList" parameterType="TestCaseLog" resultMap="TestCaseLogResult">
|
||||
<include refid="selectTestCaseLogVo"/>
|
||||
<where>
|
||||
<if test="caseId != null and caseId != ''">and case_id = #{caseId}</if>
|
||||
<if test="caseId != null">and case_id = #{caseId}</if>
|
||||
<if test="operType != null and operType != ''">and oper_type = #{operType}</if>
|
||||
<if test="operDetail != null and operDetail != ''">and oper_detail = #{operDetail}</if>
|
||||
<if test="operUser != null ">and oper_user = #{operUser}</if>
|
||||
<if test="operTime != null ">and oper_time = #{operTime}</if>
|
||||
<if test="caseSid != null">and case_sid = #{caseSid}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
@@ -42,6 +44,7 @@
|
||||
<if test="operDetail != null">oper_detail,</if>
|
||||
<if test="operUser != null">oper_user,</if>
|
||||
<if test="operTime != null">oper_time,</if>
|
||||
<if test="caseSid != null">case_sid,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="caseId != null">#{caseId},</if>
|
||||
@@ -49,6 +52,7 @@
|
||||
<if test="operDetail != null">#{operDetail},</if>
|
||||
<if test="operUser != null">#{operUser},</if>
|
||||
<if test="operTime != null">#{operTime},</if>
|
||||
<if test="caseSid != null">#{caseSid},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
@@ -60,6 +64,7 @@
|
||||
<if test="operDetail != null">oper_detail = #{operDetail},</if>
|
||||
<if test="operUser != null">oper_user = #{operUser},</if>
|
||||
<if test="operTime != null">oper_time = #{operTime},</if>
|
||||
<if test="caseSid != null">case_sid = #{caseSid},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
@@ -20,14 +20,15 @@
|
||||
<result property="useTime" column="use_time" />
|
||||
<result property="executeTime" column="execute_time" />
|
||||
<result property="status" column="status" />
|
||||
<result property="caseSid" column="case_sid"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectTestCaseResultVo">
|
||||
select id, case_id, step_id, request_header, request_body, response_header, response_body, sql_result, polling_count, loop_count, assignment, assertion, use_time, execute_time, status from test_case_result
|
||||
select id, case_id, case_sid, step_id, request_header, request_body, response_header, response_body, sql_result, polling_count, loop_count, assignment, assertion, use_time, execute_time, status from test_case_result
|
||||
</sql>
|
||||
|
||||
<sql id="selectMinTestCaseResultVo">
|
||||
select id, case_id, step_id, polling_count, loop_count, use_time, execute_time, status from test_case_result
|
||||
select id, case_id, case_sid, step_id, polling_count, loop_count, use_time, execute_time, status from test_case_result
|
||||
</sql>
|
||||
|
||||
<select id="selectTestCaseResultList" parameterType="TestCaseResult" resultMap="TestCaseResultResult">
|
||||
@@ -47,6 +48,7 @@
|
||||
<if test="useTime != null "> and use_time = #{useTime}</if>
|
||||
<if test="executeTime != null "> and execute_time = #{executeTime}</if>
|
||||
<if test="status != null and status != ''"> and status = #{status}</if>
|
||||
<if test="caseSid != null">and case_sid = #{caseSid}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
@@ -58,6 +60,7 @@
|
||||
<if test="useTime != null "> and use_time = #{useTime}</if>
|
||||
<if test="executeTime != null "> and execute_time = #{executeTime}</if>
|
||||
<if test="status != null and status != ''"> and status = #{status}</if>
|
||||
<if test="caseSid != null">and case_sid = #{caseSid}</if>
|
||||
</where>
|
||||
order by execute_time desc
|
||||
</select>
|
||||
@@ -84,6 +87,7 @@
|
||||
<if test="useTime != null">use_time,</if>
|
||||
<if test="executeTime != null">execute_time,</if>
|
||||
<if test="status != null">status,</if>
|
||||
<if test="caseSid != null">case_sid,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="caseId != null">#{caseId},</if>
|
||||
@@ -100,6 +104,7 @@
|
||||
<if test="useTime != null">#{useTime},</if>
|
||||
<if test="executeTime != null">#{executeTime},</if>
|
||||
<if test="status != null">#{status},</if>
|
||||
<if test="caseSid != null">#{caseSid},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
@@ -120,6 +125,7 @@
|
||||
<if test="useTime != null">use_time = #{useTime},</if>
|
||||
<if test="executeTime != null">execute_time = #{executeTime},</if>
|
||||
<if test="status != null">status = #{status},</if>
|
||||
<if test="caseSid != null">case_sid = #{caseSid},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
Reference in New Issue
Block a user