feat(接口测试首页): #1002984 接口增加全局的覆盖率统计
【12.接口增加全局的覆盖率统计,无论是单用例还是场景步骤都算覆盖】https://www.tapd.cn/55049933/prong/stories/view/1155049933001002984
This commit is contained in:
parent
305db60aea
commit
4931c7816b
|
@ -272,6 +272,27 @@ public class APITestController {
|
||||||
return apiCountResult;
|
return apiCountResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("/countApiCoverage/{projectId}")
|
||||||
|
public String countApiCoverage(@PathVariable String projectId) {
|
||||||
|
String returnStr = "100%";
|
||||||
|
/**
|
||||||
|
* 接口覆盖率
|
||||||
|
* 接口有案例/被场景引用 : 所有的接口
|
||||||
|
*/
|
||||||
|
long effectiveApiCount = apiDefinitionService.countEffectiveByProjectId(projectId);
|
||||||
|
long sourceIdCount = apiDefinitionService.countQuotedApiByProjectId(projectId);
|
||||||
|
try {
|
||||||
|
if(sourceIdCount != 0){
|
||||||
|
float coverageRageNumber = (float) sourceIdCount * 100 / effectiveApiCount;
|
||||||
|
DecimalFormat df = new DecimalFormat("0.0");
|
||||||
|
returnStr = df.format(coverageRageNumber) + "%";
|
||||||
|
}
|
||||||
|
}catch (Exception e){
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return returnStr;
|
||||||
|
}
|
||||||
|
|
||||||
@GetMapping("/countInterfaceCoverage/{projectId}")
|
@GetMapping("/countInterfaceCoverage/{projectId}")
|
||||||
public String countInterfaceCoverage(@PathVariable String projectId) {
|
public String countInterfaceCoverage(@PathVariable String projectId) {
|
||||||
String returnStr = "100%";
|
String returnStr = "100%";
|
||||||
|
|
|
@ -1446,4 +1446,18 @@ public class ApiDefinitionService {
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public long countEffectiveByProjectId(String projectId) {
|
||||||
|
if(StringUtils.isEmpty(projectId)){
|
||||||
|
return 0;
|
||||||
|
}else {
|
||||||
|
ApiDefinitionExample example = new ApiDefinitionExample();
|
||||||
|
example.createCriteria().andProjectIdEqualTo(projectId).andStatusNotEqualTo("Trash");
|
||||||
|
return apiDefinitionMapper.countByExample(example);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public long countQuotedApiByProjectId(String projectId) {
|
||||||
|
return extApiDefinitionMapper.countQuotedApiByProjectId(projectId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,4 +67,5 @@ public interface ExtApiDefinitionMapper {
|
||||||
|
|
||||||
Long getLastOrder(@Param("projectId")String projectId, @Param("baseOrder") Long baseOrder);
|
Long getLastOrder(@Param("projectId")String projectId, @Param("baseOrder") Long baseOrder);
|
||||||
|
|
||||||
|
long countQuotedApiByProjectId(String projectId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -651,4 +651,21 @@
|
||||||
</if>
|
</if>
|
||||||
order by `order` desc limit 1;
|
order by `order` desc limit 1;
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="countQuotedApiByProjectId" resultType="java.lang.Long">
|
||||||
|
SELECT COUNT(id) FROM api_definition
|
||||||
|
WHERE project_id = #{0} AND `status` != 'Trash'
|
||||||
|
AND (
|
||||||
|
id IN (
|
||||||
|
SELECT reference_id FROM api_scenario_reference_id WHERE api_scenario_id in (
|
||||||
|
SELECT id FROM api_scenario WHERE `status` is null or `status` != 'Trash'
|
||||||
|
)
|
||||||
|
)
|
||||||
|
OR
|
||||||
|
id IN (
|
||||||
|
SELECT api_definition_id FROM api_test_case WHERE `status` is null or `status` != 'Trash'
|
||||||
|
)
|
||||||
|
)
|
||||||
|
</select>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
<ms-main-container v-loading="result.loading">
|
<ms-main-container v-loading="result.loading">
|
||||||
<el-row :gutter="10">
|
<el-row :gutter="10">
|
||||||
<el-col :span="6">
|
<el-col :span="6">
|
||||||
<ms-api-info-card @redirectPage="redirectPage" :api-count-data="apiCountData"/>
|
<ms-api-info-card @redirectPage="redirectPage" :api-count-data="apiCountData" :interface-coverage="apiCoverage"/>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="6">
|
<el-col :span="6">
|
||||||
<ms-test-case-info-card @redirectPage="redirectPage" :test-case-count-data="testCaseCountData"/>
|
<ms-test-case-info-card @redirectPage="redirectPage" :test-case-count-data="testCaseCountData"/>
|
||||||
|
@ -58,6 +58,7 @@ export default {
|
||||||
testCaseCountData: {},
|
testCaseCountData: {},
|
||||||
scheduleTaskCountData: {},
|
scheduleTaskCountData: {},
|
||||||
interfaceCoverage: "waitting...",
|
interfaceCoverage: "waitting...",
|
||||||
|
apiCoverage: "waitting...",
|
||||||
result: {},
|
result: {},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -77,11 +78,16 @@ export default {
|
||||||
this.$get("/api/testSceneInfoCount/" + selectProjectId, response => {
|
this.$get("/api/testSceneInfoCount/" + selectProjectId, response => {
|
||||||
this.sceneCountData = response.data;
|
this.sceneCountData = response.data;
|
||||||
});
|
});
|
||||||
|
this.apiCoverage = "waitting...",
|
||||||
this.interfaceCoverage = "waitting...";
|
this.interfaceCoverage = "waitting...";
|
||||||
this.$get("/api/countInterfaceCoverage/" + selectProjectId, response => {
|
this.$get("/api/countInterfaceCoverage/" + selectProjectId, response => {
|
||||||
this.interfaceCoverage = response.data;
|
this.interfaceCoverage = response.data;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.$get("/api/countApiCoverage/" + selectProjectId, response => {
|
||||||
|
this.apiCoverage = response.data;
|
||||||
|
});
|
||||||
|
|
||||||
this.$get("/api/testCaseInfoCount/" + selectProjectId, response => {
|
this.$get("/api/testCaseInfoCount/" + selectProjectId, response => {
|
||||||
this.testCaseCountData = response.data;
|
this.testCaseCountData = response.data;
|
||||||
});
|
});
|
||||||
|
|
|
@ -68,10 +68,10 @@
|
||||||
</el-col>
|
</el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
</el-header>
|
</el-header>
|
||||||
<el-main style="padding: 5px;margin-top: 10px">
|
<el-main style="padding: 5px 5px 0px 5px;margin-top: 10px">
|
||||||
<el-container>
|
<!-- <el-container>-->
|
||||||
<el-aside width="60%" class="count-number-show" style="margin-bottom: 0px;margin-top: 0px">
|
<!-- <el-aside width="60%" class="count-number-show" style="margin-bottom: 0px;margin-top: 0px">-->
|
||||||
<el-container>
|
<!-- <el-container>
|
||||||
<el-aside width="30%">
|
<el-aside width="30%">
|
||||||
{{ $t('api_test.home_page.detail_card.rate.completion') + ":" }}
|
{{ $t('api_test.home_page.detail_card.rate.completion') + ":" }}
|
||||||
</el-aside>
|
</el-aside>
|
||||||
|
@ -84,6 +84,39 @@
|
||||||
</el-tooltip>
|
</el-tooltip>
|
||||||
</span>
|
</span>
|
||||||
</el-main>
|
</el-main>
|
||||||
|
</el-container>-->
|
||||||
|
<el-container>
|
||||||
|
<el-aside width="60%" class="count-number-show" style="margin-bottom: 0px;margin-top: 0px">
|
||||||
|
<el-container style="height: 50px;margin-top: 10px">
|
||||||
|
<el-aside width="50%" style="line-height: 40px;">
|
||||||
|
{{$t('api_test.home_page.detail_card.rate.completion')+":"}}
|
||||||
|
</el-aside>
|
||||||
|
<el-main style="padding: 0px 0px 0px 0px; line-height: 40px; text-align: center;">
|
||||||
|
<span class="rows-count-number">
|
||||||
|
{{ apiCountData.completionRage }}
|
||||||
|
<el-tooltip placement="top" class="info-tool-tip">
|
||||||
|
<div slot="content">{{ $t('api_test.home_page.formula.completion')}}</div>
|
||||||
|
<el-button icon="el-icon-info" style="padding:0px;border: 0px"></el-button>
|
||||||
|
</el-tooltip>
|
||||||
|
</span>
|
||||||
|
</el-main>
|
||||||
|
</el-container>
|
||||||
|
<el-container style="height: 50px;margin-top: 1px">
|
||||||
|
<el-aside width="50%" style="line-height: 40px;">
|
||||||
|
<span>{{$t('api_test.home_page.detail_card.rate.interface_coverage')+":"}}</span>
|
||||||
|
</el-aside>
|
||||||
|
<el-main style="padding: 0px 0px 0px 0px; line-height: 40px; text-align: center;">
|
||||||
|
<span v-if="interfaceCoverage === 'waitting...'">
|
||||||
|
<i class="el-icon-loading lading-icon"></i>
|
||||||
|
</span>
|
||||||
|
<span v-else class="rows-count-number">
|
||||||
|
{{interfaceCoverage}}
|
||||||
|
<el-tooltip placement="top" class="info-tool-tip">
|
||||||
|
<div slot="content">{{ $t('api_test.home_page.formula.api_coverage')}}</div>
|
||||||
|
<el-button icon="el-icon-info" style="padding:0px;border: 0px"></el-button>
|
||||||
|
</el-tooltip>
|
||||||
|
</span>
|
||||||
|
</el-main>
|
||||||
</el-container>
|
</el-container>
|
||||||
</el-aside>
|
</el-aside>
|
||||||
<el-main style="padding: 5px">
|
<el-main style="padding: 5px">
|
||||||
|
@ -142,6 +175,7 @@ export default {
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
apiCountData: {},
|
apiCountData: {},
|
||||||
|
interfaceCoverage:String,
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
redirectPage(clickType) {
|
redirectPage(clickType) {
|
||||||
|
@ -163,6 +197,14 @@ export default {
|
||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.rows-count-number{
|
||||||
|
font-family:'ArialMT', 'Arial', sans-serif;
|
||||||
|
font-size:19px;
|
||||||
|
color: var(--count_number);
|
||||||
|
margin:20px auto;
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
.main-number-show {
|
.main-number-show {
|
||||||
width: 100px;
|
width: 100px;
|
||||||
height: 100px;
|
height: 100px;
|
||||||
|
|
|
@ -1261,6 +1261,7 @@ export default {
|
||||||
pass: "scenarios whitch final execute is sucess / all scenarios * 100%",
|
pass: "scenarios whitch final execute is sucess / all scenarios * 100%",
|
||||||
success: "execute success count number / all execute count number * 100%",
|
success: "execute success count number / all execute count number * 100%",
|
||||||
interface_coverage: "api whitch in scenario's step / all api * 100%",
|
interface_coverage: "api whitch in scenario's step / all api * 100%",
|
||||||
|
api_coverage: "api whitch have case or in scenario's step / all api * 100%",
|
||||||
review: "reviewed cases / all cases * 100%",
|
review: "reviewed cases / all cases * 100%",
|
||||||
testplan_coverage: "relevance function cases / all function cases * 100%",
|
testplan_coverage: "relevance function cases / all function cases * 100%",
|
||||||
},
|
},
|
||||||
|
|
|
@ -1269,6 +1269,7 @@ export default {
|
||||||
pass: "最后一次执行成功的场景/场景总数*100%",
|
pass: "最后一次执行成功的场景/场景总数*100%",
|
||||||
success: "执行成功的次数/执行总次数*100%",
|
success: "执行成功的次数/执行总次数*100%",
|
||||||
interface_coverage: "被场景步骤包含的接口/接口总数*100%",
|
interface_coverage: "被场景步骤包含的接口/接口总数*100%",
|
||||||
|
api_coverage: "存在用例或被场景步骤包含的接口/接口总数*100%",
|
||||||
review: "已评审的功能案例/所有功能案例 * 100%",
|
review: "已评审的功能案例/所有功能案例 * 100%",
|
||||||
testplan_coverage: "关联的功能案例/所有功能案例 * 100%",
|
testplan_coverage: "关联的功能案例/所有功能案例 * 100%",
|
||||||
},
|
},
|
||||||
|
|
|
@ -1270,6 +1270,7 @@ export default {
|
||||||
pass: "最後一次執行成功的場景/場景總數*100%",
|
pass: "最後一次執行成功的場景/場景總數*100%",
|
||||||
success: "執行成功的次數/執行總次數*100%",
|
success: "執行成功的次數/執行總次數*100%",
|
||||||
interface_coverage: "被場景步驟包含的接口/接口總數*100%",
|
interface_coverage: "被場景步驟包含的接口/接口總數*100%",
|
||||||
|
api_coverage: "存在用例或被場景步驟包含的接口/接口總數*100%",
|
||||||
review: "已評審的功能案例/所有功能案例 * 100%",
|
review: "已評審的功能案例/所有功能案例 * 100%",
|
||||||
testplan_coverage: "關聯的功能案例/所有功能案例 * 100%",
|
testplan_coverage: "關聯的功能案例/所有功能案例 * 100%",
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue