sql系统异常增加结果记录
This commit is contained in:
@@ -185,10 +185,10 @@ public class TestCaseServiceImpl implements ITestCaseService
|
|||||||
* @return 成功或失败
|
* @return 成功或失败
|
||||||
*/
|
*/
|
||||||
private boolean doHttpRequestTest(TestCase testCase, TestCaseStep testCaseStep, String jmeterHomePath) {
|
private boolean doHttpRequestTest(TestCase testCase, TestCaseStep testCaseStep, String jmeterHomePath) {
|
||||||
|
TestCaseResult testCaseResult = new TestCaseResult();
|
||||||
try {
|
try {
|
||||||
String assignment = testCaseStep.getAssignment(); // 参数提取
|
String assignment = testCaseStep.getAssignment(); // 参数提取
|
||||||
String assertion = testCaseStep.getAssertion(); // 校验规则
|
String assertion = testCaseStep.getAssertion(); // 校验规则
|
||||||
TestCaseResult testCaseResult = new TestCaseResult();
|
|
||||||
testCaseResult.setExecuteTime(DateUtils.getNowDate());
|
testCaseResult.setExecuteTime(DateUtils.getNowDate());
|
||||||
Map<String, String> resultMap = testCaseStepService.executeJmeterTestCaseStepById(testCaseStep.getId(), jmeterHomePath);
|
Map<String, String> resultMap = testCaseStepService.executeJmeterTestCaseStepById(testCaseStep.getId(), jmeterHomePath);
|
||||||
testCaseResult.setCaseId(testCase.getId());
|
testCaseResult.setCaseId(testCase.getId());
|
||||||
@@ -226,6 +226,9 @@ public class TestCaseServiceImpl implements ITestCaseService
|
|||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("HTTP请求测试发生异常: ", e);
|
log.error("HTTP请求测试发生异常: ", e);
|
||||||
|
testCaseResult.setUseTime(0L);
|
||||||
|
testCaseResult.setStatus("失败");
|
||||||
|
testCaseResultMapper.insertTestCaseResult(testCaseResult);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -238,11 +241,13 @@ public class TestCaseServiceImpl implements ITestCaseService
|
|||||||
* @return 成功或失败
|
* @return 成功或失败
|
||||||
*/
|
*/
|
||||||
private boolean doDateSourceRequestTest(TestCase testCase, TestCaseStep testCaseStep) {
|
private boolean doDateSourceRequestTest(TestCase testCase, TestCaseStep testCaseStep) {
|
||||||
|
TestCaseResult testCaseResult = new TestCaseResult();
|
||||||
try {
|
try {
|
||||||
String assignment = testCaseStep.getAssignment(); // 参数提取
|
String assignment = testCaseStep.getAssignment(); // 参数提取
|
||||||
String assertion = testCaseStep.getAssertion(); // 校验规则
|
String assertion = testCaseStep.getAssertion(); // 校验规则
|
||||||
TestCaseResult testCaseResult = new TestCaseResult();
|
|
||||||
testCaseResult.setExecuteTime(DateUtils.getNowDate());
|
testCaseResult.setExecuteTime(DateUtils.getNowDate());
|
||||||
|
testCaseResult.setCaseId(testCase.getId());
|
||||||
|
testCaseResult.setStepId(testCaseStep.getId());
|
||||||
Long startTime = System.currentTimeMillis();
|
Long startTime = System.currentTimeMillis();
|
||||||
TestDatasource testDatasource = testDatasourceMapper.selectTestDatasourceById(testCaseStep.getDatasourceId());
|
TestDatasource testDatasource = testDatasourceMapper.selectTestDatasourceById(testCaseStep.getDatasourceId());
|
||||||
Long useTime = System.currentTimeMillis() - startTime;
|
Long useTime = System.currentTimeMillis() - startTime;
|
||||||
@@ -255,8 +260,6 @@ public class TestCaseServiceImpl implements ITestCaseService
|
|||||||
List<String> columnNameList = new ArrayList<>();
|
List<String> columnNameList = new ArrayList<>();
|
||||||
// 获取所有sql查询集合对象
|
// 获取所有sql查询集合对象
|
||||||
List<Map<String, Object>> resultMapList = MySQLExecutor.executeQuery(testCaseStep.getSqlCommand(), url, testDatasource.getUsername(), testDatasource.getPassword(), columnNameList);
|
List<Map<String, Object>> resultMapList = MySQLExecutor.executeQuery(testCaseStep.getSqlCommand(), url, testDatasource.getUsername(), testDatasource.getPassword(), columnNameList);
|
||||||
testCaseResult.setCaseId(testCase.getId());
|
|
||||||
testCaseResult.setStepId(testCaseStep.getId());
|
|
||||||
if (!CollectionUtils.isEmpty(resultMapList)) {
|
if (!CollectionUtils.isEmpty(resultMapList)) {
|
||||||
SqlResult sqlResult = new SqlResult();
|
SqlResult sqlResult = new SqlResult();
|
||||||
sqlResult.setColumnNameList(columnNameList);
|
sqlResult.setColumnNameList(columnNameList);
|
||||||
@@ -290,6 +293,9 @@ public class TestCaseServiceImpl implements ITestCaseService
|
|||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("数据源请求测试发生异常: ", e);
|
log.error("数据源请求测试发生异常: ", e);
|
||||||
|
testCaseResult.setSqlResult("数据源请求测试发生异常: " + e.getMessage());
|
||||||
|
testCaseResult.setStatus("失败");
|
||||||
|
testCaseResultMapper.insertTestCaseResult(testCaseResult);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
Reference in New Issue
Block a user