feat(接口自动化): 报告优化
This commit is contained in:
parent
e451248e25
commit
86b19b68fc
|
@ -40,20 +40,26 @@ public class TestResult {
|
||||||
this.passAssertions += count;
|
this.passAssertions += count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static final String separator = "<->";
|
||||||
|
|
||||||
public void addScenario(ScenarioResult result) {
|
public void addScenario(ScenarioResult result) {
|
||||||
Map<String, List<RequestResult>> requestResultMap = new LinkedHashMap<>();
|
Map<String, List<RequestResult>> requestResultMap = new LinkedHashMap<>();
|
||||||
if (result != null && CollectionUtils.isNotEmpty(result.getRequestResults())) {
|
if (result != null && CollectionUtils.isNotEmpty(result.getRequestResults())) {
|
||||||
result.getRequestResults().forEach(item -> {
|
result.getRequestResults().forEach(item -> {
|
||||||
if (StringUtils.isNotEmpty(item.getName()) && item.getName().indexOf("<->") != -1) {
|
if (StringUtils.isNotEmpty(item.getName()) && item.getName().indexOf(separator) != -1) {
|
||||||
String array[] = item.getName().split("<->");
|
String array[] = item.getName().split(separator);
|
||||||
item.setName(array[0]);
|
String scenarioName = array[array.length - 1];
|
||||||
if (requestResultMap.containsKey(array[1])) {
|
item.setName(item.getName().replace(separator + scenarioName, ""));
|
||||||
requestResultMap.get(array[1]).add(item);
|
if (requestResultMap.containsKey(scenarioName)) {
|
||||||
|
requestResultMap.get(scenarioName).add(item);
|
||||||
} else {
|
} else {
|
||||||
List<RequestResult> requestResults = new LinkedList<>();
|
List<RequestResult> requestResults = new LinkedList<>();
|
||||||
requestResults.add(item);
|
requestResults.add(item);
|
||||||
requestResultMap.put(array[1], requestResults);
|
requestResultMap.put(scenarioName, requestResults);
|
||||||
}
|
}
|
||||||
|
item.getSubRequestResults().forEach(subItem -> {
|
||||||
|
subItem.setName(item.getName());
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -441,6 +441,7 @@ public class ApiAutomationService {
|
||||||
ParameterConfig config = new ParameterConfig();
|
ParameterConfig config = new ParameterConfig();
|
||||||
config.setConfig(envConfig);
|
config.setConfig(envConfig);
|
||||||
HashTree hashTree = request.getTestElement().generateHashTree(config);
|
HashTree hashTree = request.getTestElement().generateHashTree(config);
|
||||||
|
|
||||||
// 调用执行方法
|
// 调用执行方法
|
||||||
createScenarioReport(request.getId(), request.getScenarioId(), request.getScenarioName(), ReportTriggerMode.MANUAL.name(), request.getExecuteType(), request.getProjectId(),
|
createScenarioReport(request.getId(), request.getScenarioId(), request.getScenarioName(), ReportTriggerMode.MANUAL.name(), request.getExecuteType(), request.getProjectId(),
|
||||||
SessionUtils.getUserId());
|
SessionUtils.getUserId());
|
||||||
|
|
|
@ -9,14 +9,21 @@
|
||||||
<main v-if="this.isNotRunning">
|
<main v-if="this.isNotRunning">
|
||||||
<ms-metric-chart :content="content" :totalTime="totalTime"/>
|
<ms-metric-chart :content="content" :totalTime="totalTime"/>
|
||||||
<div>
|
<div>
|
||||||
|
<!--<ms-scenario-results :scenarios="content.scenarios" v-on:requestResult="requestResult"/>-->
|
||||||
|
|
||||||
|
<el-tabs v-model="activeName" @tab-click="handleClick">
|
||||||
|
<el-tab-pane :label="$t('api_report.total')" name="total">
|
||||||
<ms-scenario-results :scenarios="content.scenarios" v-on:requestResult="requestResult"/>
|
<ms-scenario-results :scenarios="content.scenarios" v-on:requestResult="requestResult"/>
|
||||||
|
</el-tab-pane>
|
||||||
|
<el-tab-pane name="fail">
|
||||||
|
<template slot="label">
|
||||||
|
<span class="fail">{{ $t('api_report.fail') }}</span>
|
||||||
|
</template>
|
||||||
|
<ms-scenario-results v-on:requestResult="requestResult" :scenarios="fails"/>
|
||||||
|
</el-tab-pane>
|
||||||
|
</el-tabs>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<!--<el-collapse-transition>-->
|
|
||||||
<!--<div v-show="isActive" style="width: 99%">-->
|
|
||||||
<!--<ms-request-result-tail v-if="isRequestResult" :request-type="requestType" :request="request"-->
|
|
||||||
<!--:scenario-name="scenarioName"/>-->
|
|
||||||
<!--</div>-->
|
|
||||||
<!--</el-collapse-transition>-->
|
|
||||||
<ms-api-report-export v-if="reportExportVisible" id="apiTestReport" :title="report.testName"
|
<ms-api-report-export v-if="reportExportVisible" id="apiTestReport" :title="report.testName"
|
||||||
:content="content" :total-time="totalTime"/>
|
:content="content" :total-time="totalTime"/>
|
||||||
</main>
|
</main>
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="scenario-result">
|
<div class="scenario-result" v-if="scenario && scenario.requestResults && scenario.requestResults.length>0">
|
||||||
|
|
||||||
<div @click="active">
|
<div @click="active">
|
||||||
<el-row :gutter="10" type="flex" align="middle" class="info">
|
<el-row :gutter="10" type="flex" align="middle" class="info">
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<template>
|
<template>
|
||||||
<div style="min-width: 1200px;margin-bottom: 20px">
|
<div style="margin-bottom: 20px">
|
||||||
<span class="kv-description" v-if="description">
|
<span class="kv-description" v-if="description">
|
||||||
{{ description }}
|
{{ description }}
|
||||||
</span>
|
</span>
|
||||||
|
|
|
@ -28,18 +28,15 @@
|
||||||
<el-row v-if="body.type == 'Form Data' || body.type == 'WWW_FORM'">
|
<el-row v-if="body.type == 'Form Data' || body.type == 'WWW_FORM'">
|
||||||
<el-link class="ms-el-link" @click="batchAdd"> {{$t("commons.batch_add")}}</el-link>
|
<el-link class="ms-el-link" @click="batchAdd"> {{$t("commons.batch_add")}}</el-link>
|
||||||
</el-row>
|
</el-row>
|
||||||
|
<div style="min-width: 1200px;" v-if="body.type == 'Form Data' || body.type == 'WWW_FORM'">
|
||||||
<ms-api-variable :is-read-only="isReadOnly"
|
<ms-api-variable :is-read-only="isReadOnly"
|
||||||
:parameters="body.kvs"
|
:parameters="body.kvs"
|
||||||
:isShowEnable="isShowEnable"
|
:isShowEnable="isShowEnable" type="body" v-if="body.type == 'Form Data'"/>
|
||||||
type="body"
|
|
||||||
v-if="body.type == 'Form Data'"/>
|
|
||||||
|
|
||||||
<ms-api-from-url-variable :is-read-only="isReadOnly"
|
<ms-api-from-url-variable :is-read-only="isReadOnly"
|
||||||
:parameters="body.kvs"
|
:parameters="body.kvs"
|
||||||
type="body"
|
type="body" v-if="body.type == 'WWW_FORM'"/>
|
||||||
v-if="body.type == 'WWW_FORM'"/>
|
</div>
|
||||||
|
|
||||||
<div v-if="body.type == 'JSON'">
|
<div v-if="body.type == 'JSON'">
|
||||||
<div style="padding: 10px">
|
<div style="padding: 10px">
|
||||||
<el-switch active-text="JSON-SCHEMA" v-model="body.format" active-value="JSON-SCHEMA"/>
|
<el-switch active-text="JSON-SCHEMA" v-model="body.format" active-value="JSON-SCHEMA"/>
|
||||||
|
|
|
@ -3,12 +3,12 @@
|
||||||
<el-tabs v-model="activeName" @tab-click="handleClick">
|
<el-tabs v-model="activeName" @tab-click="handleClick">
|
||||||
<el-tab-pane :label="$t('organization.message.template')" name="apiTemplate">
|
<el-tab-pane :label="$t('organization.message.template')" name="apiTemplate">
|
||||||
<el-button type="primary" size="mini" style="margin-left: 10px" @click="openOneClickOperation">导入</el-button>
|
<el-button type="primary" size="mini" style="margin-left: 10px" @click="openOneClickOperation">导入</el-button>
|
||||||
<div style="min-height: 400px">
|
<div style="min-height: 200px">
|
||||||
<json-schema-editor class="schema" :value="schema" lang="zh_CN" custom/>
|
<json-schema-editor class="schema" :value="schema" lang="zh_CN" custom/>
|
||||||
</div>
|
</div>
|
||||||
</el-tab-pane>
|
</el-tab-pane>
|
||||||
<el-tab-pane :label="$t('schema.preview')" name="preview">
|
<el-tab-pane :label="$t('schema.preview')" name="preview">
|
||||||
<div style="min-height: 400px">
|
<div style="min-height: 200px">
|
||||||
<pre>{{this.preview}}</pre>
|
<pre>{{this.preview}}</pre>
|
||||||
</div>
|
</div>
|
||||||
</el-tab-pane>
|
</el-tab-pane>
|
||||||
|
|
Loading…
Reference in New Issue