report
This commit is contained in:
@@ -87,7 +87,6 @@ public class TestCaseController extends BaseController {
|
||||
@PostMapping("/run")
|
||||
public AjaxResult run(@RequestBody IDQO qo) {
|
||||
log.info("执行用例 id:{}, jmeterHomePath:{}", qo.getId(), jmeterHomePath);
|
||||
testCaseService.executeTestCaseById(qo.getId(), jmeterHomePath);
|
||||
return toAjax(true);
|
||||
return success(testCaseService.executeTestCaseById(qo.getId(), jmeterHomePath));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.test.test.controller;
|
||||
|
||||
import com.test.common.core.controller.BaseController;
|
||||
import com.test.common.core.domain.AjaxResult;
|
||||
import com.test.test.domain.TestCaseResult;
|
||||
import com.test.test.domain.qo.IDQO;
|
||||
import com.test.test.service.ITestCaseResultService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -28,4 +29,11 @@ public class TestCaseResultController extends BaseController
|
||||
{
|
||||
return success(testCaseResultService.selectTestCaseResultById(qo.getId()));
|
||||
}
|
||||
|
||||
@GetMapping("/list")
|
||||
public AjaxResult getList(@RequestParam String sid) {
|
||||
TestCaseResult testCaseResult = new TestCaseResult();
|
||||
testCaseResult.setCaseSid(sid);
|
||||
return success(testCaseResultService.selectTestCaseResultList(testCaseResult));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.test.test.domain.vo;
|
||||
|
||||
import com.test.test.domain.TestCaseResult;
|
||||
import com.test.test.domain.TestCaseStep;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class TestCaseResultVO {
|
||||
TestCaseStep step;
|
||||
TestCaseResult result;
|
||||
}
|
||||
@@ -68,5 +68,5 @@ public interface ITestCaseService
|
||||
* @param jmeterHomePath jmeter安装路径
|
||||
* @return 是否成功
|
||||
*/
|
||||
public boolean executeTestCaseById(Long id, String jmeterHomePath);
|
||||
public String executeTestCaseById(Long id, String jmeterHomePath);
|
||||
}
|
||||
|
||||
@@ -139,18 +139,18 @@ public class TaskManagerService {
|
||||
try {
|
||||
// 测试用例执行逻辑
|
||||
log.info("Executing test case {} for task {}", testCaseId, taskId);
|
||||
boolean result = testCaseService.executeTestCaseById(testCaseId, jmeterHomePath);
|
||||
if (!result && retry == 0) {
|
||||
String result = testCaseService.executeTestCaseById(testCaseId, jmeterHomePath);
|
||||
if (result==null && retry == 0) {
|
||||
if (retryCount != null && retryCount > 0) {
|
||||
for (int i = 0; i < retryCount; i++) {
|
||||
result = testCaseService.executeTestCaseById(testCaseId, jmeterHomePath);
|
||||
if (result) {
|
||||
if (result!=null) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
return result!=null;
|
||||
} catch (Exception e) {
|
||||
log.error("Test case {} for task {} failed: ", testCaseId, taskId, e);
|
||||
return false;
|
||||
|
||||
@@ -135,11 +135,11 @@ public class TestCaseServiceImpl implements ITestCaseService
|
||||
* @return 是否成功
|
||||
*/
|
||||
@Override
|
||||
public boolean executeTestCaseById(Long id, String jmeterHomePath) {
|
||||
public String executeTestCaseById(Long id, String jmeterHomePath) {
|
||||
TestCase testCase = this.selectTestCaseById(id);
|
||||
if (testCase == null || "2".equals(testCase.getDelFlag())) {
|
||||
log.error("用例计划已被删除,不能执行!");
|
||||
return false;
|
||||
return null;
|
||||
}
|
||||
TestCaseLog testCaseLog = new TestCaseLog();
|
||||
testCaseLog.setCaseId(id);
|
||||
@@ -157,7 +157,7 @@ public class TestCaseServiceImpl implements ITestCaseService
|
||||
testCaseLog.setOperDetail("失败");
|
||||
testCaseLogMapper.insertTestCaseLog(testCaseLog);
|
||||
log.error("用例步骤:{}执行失败!", testCaseStep.getName());
|
||||
return false;
|
||||
return null;
|
||||
}
|
||||
} else if (testCaseStep.getType() == 2L) {
|
||||
// 数据库接口处理
|
||||
@@ -166,7 +166,7 @@ public class TestCaseServiceImpl implements ITestCaseService
|
||||
testCaseLog.setOperDetail("失败");
|
||||
testCaseLogMapper.insertTestCaseLog(testCaseLog);
|
||||
log.error("数据源用例步骤:{}执行失败!", testCaseStep.getName());
|
||||
return false;
|
||||
return null;
|
||||
}
|
||||
} else if (testCaseStep.getType() == 3L) {
|
||||
// 循环节点处理
|
||||
@@ -175,7 +175,7 @@ public class TestCaseServiceImpl implements ITestCaseService
|
||||
testCaseLog.setOperDetail("失败");
|
||||
testCaseLogMapper.insertTestCaseLog(testCaseLog);
|
||||
log.error("循环用例步骤:{}执行失败!", testCaseStep.getName());
|
||||
return false;
|
||||
return null;
|
||||
}
|
||||
} else if (testCaseStep.getType() == 4L) {
|
||||
// 轮询节点处理
|
||||
@@ -184,7 +184,7 @@ public class TestCaseServiceImpl implements ITestCaseService
|
||||
testCaseLog.setOperDetail("失败");
|
||||
testCaseLogMapper.insertTestCaseLog(testCaseLog);
|
||||
log.error("轮询用例步骤:{}执行失败!", testCaseStep.getName());
|
||||
return false;
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
log.error("错误的用例步骤类型!");
|
||||
@@ -192,7 +192,7 @@ public class TestCaseServiceImpl implements ITestCaseService
|
||||
}
|
||||
testCaseLog.setOperDetail("成功");
|
||||
testCaseLogMapper.insertTestCaseLog(testCaseLog);
|
||||
return true;
|
||||
return caseSid;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -54,3 +54,12 @@ export function delCaseStep(id) {
|
||||
data: {id}
|
||||
})
|
||||
}
|
||||
|
||||
// 查询步骤日志详细
|
||||
export function getCaseResult(sid) {
|
||||
return request({
|
||||
url: '/test/testCaseStepResult/list',
|
||||
method: 'get',
|
||||
params: {sid: sid}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -22,19 +22,26 @@
|
||||
<pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList"/>
|
||||
</div>
|
||||
<el-empty v-else/>
|
||||
<el-dialog title="操作日志详细" :visible.sync="open" >
|
||||
<div v-if="open">
|
||||
<report :sid="caseSID"/>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</folder-page>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import FolderPage from "@/components/FolderPage/index.vue";
|
||||
import Report from "@/views/test/case/report/index.vue";
|
||||
import {addCase, delCase, listCase, runCase} from "@/api/test/case";
|
||||
|
||||
export default {
|
||||
name: "Case",
|
||||
components: {FolderPage},
|
||||
components: {FolderPage, Report},
|
||||
data() {
|
||||
return {
|
||||
loading: false,
|
||||
open: false,
|
||||
showSearch: true,
|
||||
total: 0,
|
||||
dataList: [],
|
||||
@@ -43,6 +50,7 @@ export default {
|
||||
pageSize: 10,
|
||||
groupId: null,
|
||||
},
|
||||
caseSID: null,
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
@@ -83,8 +91,10 @@ export default {
|
||||
handleRun(id) {
|
||||
this.$modal.confirm('是否确认执行用例?').then(function () {
|
||||
return runCase(id);
|
||||
}).then(() => {
|
||||
}).then((res) => {
|
||||
this.$modal.msgSuccess("执行成功");
|
||||
this.caseSID = res.msg
|
||||
this.open = true;
|
||||
});
|
||||
},
|
||||
handleRowClick(row) {
|
||||
|
||||
@@ -5,111 +5,43 @@
|
||||
<el-button size="mini" plain type="warning" icon="el-icon-rank" circle style="margin-right: 12px" class="drag-handle"/>
|
||||
<el-tag effect="plain" style="width: 70px;text-align: center;margin-right: 12px;" class="drag-handle">{{ dict.type.step_type.findLast(t => t.value == item.type).label }}</el-tag>
|
||||
<el-tag v-if="item.name" effect="plain" style="width: 240px;text-align: center;margin-right: 12px;" type="info" class="drag-handle">{{ item.name }}</el-tag>
|
||||
<el-tag v-if="item.datasourceId" effect="plain" style="width: 240px;text-align: center;margin-right: 12px;" type="info" class="drag-handle">{{ datasourceList.findLast(t => t.id === item.datasourceId).name }}</el-tag>
|
||||
<el-tag v-if="item.datasourceId && item.type < 3" effect="plain" style="width: 240px;text-align: center;margin-right: 12px;" type="info" class="drag-handle">{{ datasourceList.findLast(t => t.id === item.datasourceId).name }}</el-tag>
|
||||
<el-tag v-if="item.requestUrl" effect="plain" style="text-align: center;margin-right: 12px;" type="success" class="drag-handle">{{ item.requestUrl }}</el-tag>
|
||||
<el-tag effect="plain" style="text-align: center;margin-right: 12px;" class="drag-handle">{{ index + 1 }}</el-tag>
|
||||
</template>
|
||||
<el-tabs v-model="tabsActiveName" v-if="item.type == 2 || item.type == 1">
|
||||
<el-tab-pane v-if="item.type == 1" label="Headers" name="Headers">
|
||||
<el-table :data="form.requestHeader">
|
||||
<el-table-column label="参数名">
|
||||
<template slot-scope="scope">
|
||||
<el-input placeholder="请输入参数名" v-model="form.requestHeader[scope.$index].key" @input="e => handleTableEdit(e, 'header', scope)" clearable/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="示例值">
|
||||
<template slot-scope="scope">
|
||||
<el-input placeholder="请输入参数名" v-model="form.requestHeader[scope.$index].value" @input="e => handleTableEdit(e, 'header', scope)" clearable/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="60">
|
||||
<template slot-scope="scope">
|
||||
<el-button v-if="form.requestHeader.length > scope.$index+1" size="mini" type="text" icon="el-icon-delete" @click="handleDelete('header', scope)">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="参数名" prop="key" />
|
||||
<el-table-column label="示例值" prop="value" />
|
||||
</el-table>
|
||||
</el-tab-pane>
|
||||
<el-tab-pane v-if="item.type == 1" label="Params" name="Params">
|
||||
<el-table :data="form.requestParams">
|
||||
<el-table-column label="参数名">
|
||||
<template slot-scope="scope">
|
||||
<el-input placeholder="请输入参数名" v-model="form.requestParams[scope.$index].key" @input="e => handleTableEdit(e, 'param', scope)" clearable/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="示例值">
|
||||
<template slot-scope="scope">
|
||||
<el-input placeholder="请输入示例值" v-model="form.requestParams[scope.$index].value" @input="e => handleTableEdit(e, 'param', scope)" clearable/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="60">
|
||||
<template slot-scope="scope">
|
||||
<el-button v-if="form.requestParams.length > scope.$index+1" size="mini" type="text" icon="el-icon-delete" @click="handleDelete('param', scope)">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="参数名" prop="key" />
|
||||
<el-table-column label="示例值" prop="value" />
|
||||
</el-table>
|
||||
</el-tab-pane>
|
||||
<el-tab-pane v-if="item.type == 1" label="Body" name="Body">
|
||||
<JsonEditorVue mode="text" v-model="form.requestBody" class="jse-theme-dark"/>
|
||||
<JsonEditorVue mode="text" v-model="item.requestBody" class="jse-theme-dark"/>
|
||||
</el-tab-pane>
|
||||
<el-tab-pane v-if="item.type == 2" label="SQL指令" name="sql">
|
||||
<codemirror v-model="form.sqlCommand" :options="editorOptions" />
|
||||
<div>{{item.sqlCommand}}</div>
|
||||
</el-tab-pane>
|
||||
<el-tab-pane label="提取" name="assignment">
|
||||
<el-table :data="form.assignment">
|
||||
<el-table-column label="变量名">
|
||||
<template slot-scope="scope">
|
||||
<el-input placeholder="请输入变量名" v-model="form.assignment[scope.$index].name" @input="e => handleTableEdit(e, 'assignment', scope)" clearable/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="提取方式">
|
||||
<template slot-scope="scope">
|
||||
<el-input placeholder="请输入提取方式" v-model="form.assignment[scope.$index].type" @input="e => handleTableEdit(e, 'assignment', scope)" clearable/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="提取对象">
|
||||
<template slot-scope="scope">
|
||||
<el-input placeholder="请输入提取对象" v-model="form.assignment[scope.$index].content" @input="e => handleTableEdit(e, 'assignment', scope)" clearable/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="提取表达式">
|
||||
<template slot-scope="scope">
|
||||
<el-input placeholder="请输入提取表达式" v-model="form.assignment[scope.$index].path" @input="e => handleTableEdit(e, 'assignment', scope)" clearable/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="60">
|
||||
<template slot-scope="scope">
|
||||
<el-button v-if="form.assignment.length > scope.$index+1" size="mini" type="text" icon="el-icon-delete" @click="handleDelete('assignment', scope)">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table :data="item.sqlResult">
|
||||
<el-table-column label="变量名" prop="name" />
|
||||
<el-table-column label="提取方式" prop="type" />
|
||||
<el-table-column label="提取对象" prop="content" />
|
||||
<el-table-column label="提取表达式" prop="path" />
|
||||
</el-table>
|
||||
</el-tab-pane>
|
||||
<el-tab-pane label="校验" name="assertion">
|
||||
<el-table :data="form.assertion">
|
||||
<el-table-column label="描述">
|
||||
<template slot-scope="scope">
|
||||
<el-input placeholder="请输入描述" v-model="form.assertion[scope.$index].name" @input="e => handleTableEdit(e, 'assertion', scope)" clearable/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="对象">
|
||||
<template slot-scope="scope">
|
||||
<el-input placeholder="请输入对象" v-model="form.assertion[scope.$index].source" @input="e => handleTableEdit(e, 'assertion', scope)" clearable/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="条件">
|
||||
<template slot-scope="scope">
|
||||
<el-input placeholder="请输入条件" v-model="form.assertion[scope.$index].fn" @input="e => handleTableEdit(e, 'assertion', scope)" clearable/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="内容">
|
||||
<template slot-scope="scope">
|
||||
<el-input placeholder="请输入内容" v-model="form.assertion[scope.$index].target" @input="e => handleTableEdit(e, 'assertion', scope)" clearable/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="60">
|
||||
<template slot-scope="scope">
|
||||
<el-button v-if="form.assertion.length > scope.$index+1" size="mini" type="text" icon="el-icon-delete" @click="handleDelete('assertion', scope)">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table :data="item.assertion">
|
||||
<el-table-column label="描述" prop="name" />
|
||||
<el-table-column label="对象" prop="source" />
|
||||
<el-table-column label="条件" prop="fn" />
|
||||
<el-table-column label="内容" prop="target" />
|
||||
</el-table>
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
@@ -166,64 +98,22 @@
|
||||
<JsonEditorVue mode="text" v-model="form.requestBody" class="jse-theme-dark"/>
|
||||
</el-tab-pane>
|
||||
<el-tab-pane v-if="item.type == 2" label="SQL指令" name="sql">
|
||||
<codemirror v-model="form.sqlCommand" :options="editorOptions" />
|
||||
<div>{{item.sqlCommand}}</div>
|
||||
</el-tab-pane>
|
||||
<el-tab-pane label="提取" name="assignment">
|
||||
<el-table :data="form.assignment">
|
||||
<el-table-column label="变量名">
|
||||
<template slot-scope="scope">
|
||||
<el-input placeholder="请输入变量名" v-model="form.assignment[scope.$index].name" @input="e => handleTableEdit(e, 'assignment', scope)" clearable/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="提取方式">
|
||||
<template slot-scope="scope">
|
||||
<el-input placeholder="请输入提取方式" v-model="form.assignment[scope.$index].type" @input="e => handleTableEdit(e, 'assignment', scope)" clearable/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="提取对象">
|
||||
<template slot-scope="scope">
|
||||
<el-input placeholder="请输入提取对象" v-model="form.assignment[scope.$index].content" @input="e => handleTableEdit(e, 'assignment', scope)" clearable/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="提取表达式">
|
||||
<template slot-scope="scope">
|
||||
<el-input placeholder="请输入提取表达式" v-model="form.assignment[scope.$index].path" @input="e => handleTableEdit(e, 'assignment', scope)" clearable/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="60">
|
||||
<template slot-scope="scope">
|
||||
<el-button v-if="form.assignment.length > scope.$index+1" size="mini" type="text" icon="el-icon-delete" @click="handleDelete('assignment', scope)">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table :data="item.sqlResult">
|
||||
<el-table-column label="变量名" prop="name" />
|
||||
<el-table-column label="提取方式" prop="type" />
|
||||
<el-table-column label="提取对象" prop="content" />
|
||||
<el-table-column label="提取表达式" prop="path" />
|
||||
</el-table>
|
||||
</el-tab-pane>
|
||||
<el-tab-pane label="校验" name="assertion">
|
||||
<el-table :data="form.assertion">
|
||||
<el-table-column label="描述">
|
||||
<template slot-scope="scope">
|
||||
<el-input placeholder="请输入描述" v-model="form.assertion[scope.$index].name" @input="e => handleTableEdit(e, 'assertion', scope)" clearable/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="对象">
|
||||
<template slot-scope="scope">
|
||||
<el-input placeholder="请输入对象" v-model="form.assertion[scope.$index].source" @input="e => handleTableEdit(e, 'assertion', scope)" clearable/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="条件">
|
||||
<template slot-scope="scope">
|
||||
<el-input placeholder="请输入条件" v-model="form.assertion[scope.$index].fn" @input="e => handleTableEdit(e, 'assertion', scope)" clearable/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="内容">
|
||||
<template slot-scope="scope">
|
||||
<el-input placeholder="请输入内容" v-model="form.assertion[scope.$index].target" @input="e => handleTableEdit(e, 'assertion', scope)" clearable/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="60">
|
||||
<template slot-scope="scope">
|
||||
<el-button v-if="form.assertion.length > scope.$index+1" size="mini" type="text" icon="el-icon-delete" @click="handleDelete('assertion', scope)">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table :data="item.assertion">
|
||||
<el-table-column label="描述" prop="name" />
|
||||
<el-table-column label="对象" prop="source" />
|
||||
<el-table-column label="条件" prop="fn" />
|
||||
<el-table-column label="内容" prop="target" />
|
||||
</el-table>
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
@@ -236,17 +126,46 @@
|
||||
<script>
|
||||
|
||||
import JsonEditorVue from "json-editor-vue";
|
||||
import {getCaseResult} from "@/api/test/caseStep";
|
||||
import {listDatasource} from "@/api/test/database";
|
||||
|
||||
export default {
|
||||
components: {JsonEditorVue},
|
||||
props: ["sid"],
|
||||
dicts: ['step_type'],
|
||||
data() {
|
||||
return {
|
||||
form: {},
|
||||
activeName: '',
|
||||
tabsActiveName: '',
|
||||
childrenTabsActiveName: '',
|
||||
list: []
|
||||
list: [],
|
||||
datasourceList: [],
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
listDatasource().then(res => {
|
||||
this.datasourceList = res.data;
|
||||
})
|
||||
getCaseResult(this.sid).then(res => {
|
||||
res.data.forEach(item => {
|
||||
this.list.push({
|
||||
...item.step,
|
||||
...item.result,
|
||||
})
|
||||
})
|
||||
this.list.forEach(item => {
|
||||
item = {
|
||||
...item,
|
||||
assertion: item.assertion ? JSON.parse(item.assertion) : [],
|
||||
assignment: item.assignment ? JSON.parse(item.assignment) : [],
|
||||
requestHeader: item.requestHeader ? JSON.parse(item.requestHeader) : [],
|
||||
requestParams: item.requestParams ? JSON.parse(item.requestParams) : [],
|
||||
sqlResult: item.requestParams ? JSON.parse(item.requestParams) : [],
|
||||
}
|
||||
})
|
||||
console.log(this.list)
|
||||
})
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user