This commit is contained in:
chenjianxing 2020-10-21 14:32:42 +08:00
commit 42d3e2098b
10 changed files with 32 additions and 22 deletions

View File

@ -13,12 +13,10 @@ import io.metersphere.notice.service.MailService;
import io.metersphere.notice.service.NoticeService;
import io.metersphere.track.service.TestPlanTestCaseService;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.protocol.HTTP;
import org.apache.jmeter.assertions.AssertionResult;
import org.apache.jmeter.samplers.SampleResult;
import org.apache.jmeter.visualizers.backend.AbstractBackendListenerClient;
import org.apache.jmeter.visualizers.backend.BackendListenerContext;
import org.pac4j.core.context.HttpConstants;
import org.springframework.http.HttpMethod;
import java.io.Serializable;
@ -41,6 +39,12 @@ public class APIBackendListenerClient extends AbstractBackendListenerClient impl
private APIReportService apiReportService;
private TestPlanTestCaseService testPlanTestCaseService;
private NoticeService noticeService;
private MailService mailService;
public String runMode = ApiRunMode.RUN.name();
// 测试ID
@ -60,6 +64,18 @@ public class APIBackendListenerClient extends AbstractBackendListenerClient impl
if (apiReportService == null) {
LogUtil.error("apiReportService is required");
}
testPlanTestCaseService = CommonBeanFactory.getBean(TestPlanTestCaseService.class);
if (testPlanTestCaseService == null) {
LogUtil.error("testPlanTestCaseService is required");
}
noticeService = CommonBeanFactory.getBean(NoticeService.class);
if (noticeService == null) {
LogUtil.error("noticeService is required");
}
mailService = CommonBeanFactory.getBean(MailService.class);
if (mailService == null) {
LogUtil.error("mailService is required");
}
super.setupTest(context);
}
@ -112,7 +128,7 @@ public class APIBackendListenerClient extends AbstractBackendListenerClient impl
testResult.getScenarios().addAll(scenarios.values());
testResult.getScenarios().sort(Comparator.comparing(ScenarioResult::getId));
ApiTestReport report = null;
ApiTestReport report;
if (StringUtils.equals(this.runMode, ApiRunMode.DEBUG.name())) {
report = apiReportService.get(debugReportId);
} else {
@ -123,7 +139,6 @@ public class APIBackendListenerClient extends AbstractBackendListenerClient impl
queue.clear();
super.teardownTest(context);
TestPlanTestCaseService testPlanTestCaseService = CommonBeanFactory.getBean(TestPlanTestCaseService.class);
List<String> ids = testPlanTestCaseService.getTestPlanTestCaseIds(testResult.getTestId());
if (ids.size() > 0) {
try {
@ -137,10 +152,8 @@ public class APIBackendListenerClient extends AbstractBackendListenerClient impl
}
}
NoticeService noticeService = CommonBeanFactory.getBean(NoticeService.class);
try {
List<NoticeDetail> noticeList = noticeService.queryNotice(testResult.getTestId());
MailService mailService = CommonBeanFactory.getBean(MailService.class);
mailService.sendApiNotification(report, noticeList);
} catch (Exception e) {
LogUtil.error(e);

@ -1 +1 @@
Subproject commit cf6b06526324326a563d933e07118fac014a63b4
Subproject commit ee74568be0beba46da19616f5832e83f9164c688

View File

@ -555,14 +555,6 @@ export class TCPRequest extends Request {
}
isValid() {
if (this.enable) {
if (!this.server) {
return {
isValid: false,
info: 'api_test.request.tcp.server_cannot_be_empty'
}
}
}
return {
isValid: true
}

View File

@ -243,7 +243,7 @@
:label="$t('load_test.file_type')">
</el-table-column>
<el-table-column
:label="$t('load_test.last_modify_time')">
:label="$t('test_track.case.upload_time')">
<template v-slot:default="scope">
<i class="el-icon-time"/>
<span class="last-modified">{{ scope.row.updateTime | timestampFormatDate }}</span>
@ -664,7 +664,7 @@ export default {
name: file.name,
size: file.size + ' Bytes', /// todo: ByteKBMB
type: type.toUpperCase(),
updateTime: file.lastModified,
updateTime: new Date().getTime(),
});
return true;

View File

@ -401,8 +401,7 @@ export default {
this.$success(this.$t('commons.save_success'));
this.updateTestCases(param);
this.setPlanStatus(this.testCase.planId);
// Pass
if (this.testCase.status === 'Pass' && this.index < this.testCases.length - 1) {
if (this.index < this.testCases.length - 1) {
this.handleNext();
}
});

View File

@ -39,11 +39,11 @@
<el-divider direction="vertical"></el-divider>
<el-button type="success" size="mini"
:disabled="isReadOnly" :plain="testCase.reviewStatus !== 'Pass'" @click="saveCase('Pass')">
:disabled="isReadOnly" :icon="testCase.reviewStatus === 'Pass' ? 'el-icon-check' : ''" @click="saveCase('Pass')">
{{ $t('test_track.review.pass') }}
</el-button>
<el-button type="danger" size="mini"
:disabled="isReadOnly" :plain="testCase.reviewStatus !== 'UnPass'" @click="saveCase('UnPass')">
:disabled="isReadOnly" :icon="testCase.reviewStatus === 'UnPass' ? 'el-icon-check' : ''" @click="saveCase('UnPass')">
{{ $t('test_track.review.un_pass') }}
</el-button>
</el-col>
@ -296,6 +296,9 @@ export default {
this.testCase.reviewStatus = status;
//
this.testCases[this.index].reviewStatus = status;
if (this.index < this.testCases.length - 1) {
this.handleNext();
}
});
},
updateTestCases(param) {

@ -1 +1 @@
Subproject commit 06d935cd1d22ab36f09763745c2aff8ad3fb08c1
Subproject commit cc38137a69a0f20fadece9c0f9f50a9468c4ace9

View File

@ -748,6 +748,7 @@ export default {
pdf_loading_fail: "PDF loading failed",
upload_tip: "Only jpg, jpeg, png, docx, doc, pdf, xlsx files can be uploaded",
attachment: "Attachment",
upload_time: "Upload Time",
import: {
import: "Import test case",
case_import: "Import test case",

View File

@ -752,6 +752,7 @@ export default {
pdf_loading_fail: "PDF加载失败",
upload_tip: "只能上传jpg、jpeg、png、docx、doc、pdf、xlsx文件",
attachment: "附件",
upload_time: "上传时间",
import: {
import: "导入用例",
case_import: "导入测试用例",

View File

@ -752,6 +752,7 @@ export default {
pdf_loading_fail: "PDF加載失敗",
upload_tip: "只能上傳jpg、jpeg、png、docx、doc、pdf、xlsx文件",
attachment: "附件",
upload_time: "上傳時間",
import: {
import: "導入用例",
case_import: "導入測試用例",