Merge remote-tracking branch 'origin/master'

This commit is contained in:
song.tianyang 2021-03-20 16:48:15 +08:00
commit 787909a415
17 changed files with 139 additions and 74 deletions

View File

@ -372,20 +372,20 @@
<select id="getTestPlanCase" resultType="int">
select count(s)
from (
select id as s
from test_plan_test_case tptc
select tptc.id as s
from test_plan_test_case tptc join test_case on tptc.case_id = test_case.id
where tptc.plan_id = #{planId}
union all
select id as s
from test_plan_api_scenario tpas
where tpas.test_plan_id = #{planId}
select tpas.id as s
from test_plan_api_scenario tpas join api_scenario on tpas.api_scenario_id = api_scenario.id
where tpas.test_plan_id = #{planId} and api_scenario.status != 'Trash'
union all
select id as s
from test_plan_api_case tpac
select tpac.id as s
from test_plan_api_case tpac join api_test_case on tpac.api_case_id = api_test_case.id
where tpac.test_plan_id = #{planId}
union all
select id as s
from test_plan_load_case tplc
select tplc.id as s
from test_plan_load_case tplc join load_test on tplc.load_case_id = load_test.id
where tplc.test_plan_id = #{planId}
) as temp
</select>

View File

@ -13,6 +13,7 @@ public class ShiroUtils {
public static void loadBaseFilterChain(Map<String, String> filterChainDefinitionMap){
filterChainDefinitionMap.put("/resource/**", "anon");
filterChainDefinitionMap.put("/login", "anon");
filterChainDefinitionMap.put("/signin", "anon");
filterChainDefinitionMap.put("/ldap/signin", "anon");
filterChainDefinitionMap.put("/ldap/open", "anon");

View File

@ -20,8 +20,8 @@ public class TestCaseExcelData {
private String priority;
@ExcelIgnore
private String tags;
@ExcelIgnore
private String method;
// @ExcelIgnore
// private String method;
@ExcelIgnore
private String prerequisite;
@ExcelIgnore

View File

@ -45,10 +45,10 @@ public class TestCaseExcelDataCn extends TestCaseExcelData {
@Length(min = 0, max = 1000)
private String tags;
@NotBlank(message = "{cannot_be_null}")
@ExcelProperty("测试方式")
@Pattern(regexp = "(^manual$)|(^auto$)", message = "{test_case_method_validate}")
private String method;
// @NotBlank(message = "{cannot_be_null}")
// @ExcelProperty("测试方式")
// @Pattern(regexp = "(^manual$)|(^auto$)", message = "{test_case_method_validate}")
// private String method;
@ColumnWidth(50)
@ExcelProperty("前置条件")

View File

@ -45,10 +45,10 @@ public class TestCaseExcelDataTw extends TestCaseExcelData {
@Length(min = 0, max = 1000)
private String tags;
@NotBlank(message = "{cannot_be_null}")
@ExcelProperty("測試方式")
@Pattern(regexp = "(^manual$)|(^auto$)", message = "{test_case_method_validate}")
private String method;
// @NotBlank(message = "{cannot_be_null}")
// @ExcelProperty("測試方式")
// @Pattern(regexp = "(^manual$)|(^auto$)", message = "{test_case_method_validate}")
// private String method;
@ColumnWidth(50)
@ExcelProperty("前置條件")

View File

@ -46,10 +46,10 @@ public class TestCaseExcelDataUs extends TestCaseExcelData {
@Length(min = 0, max = 1000)
private String tags;
@NotBlank(message = "{cannot_be_null}")
@ExcelProperty("Method")
@Pattern(regexp = "(^manual$)|(^auto$)", message = "{test_case_method_validate}")
private String method;
// @NotBlank(message = "{cannot_be_null}")
// @ExcelProperty("Method")
// @Pattern(regexp = "(^manual$)|(^auto$)", message = "{test_case_method_validate}")
// private String method;
@ColumnWidth(50)
@ExcelProperty("Prerequisite")

View File

@ -53,9 +53,9 @@ public class TestCaseDataListener extends EasyExcelListener<TestCaseExcelData> {
}
}
if (StringUtils.equals(data.getType(), TestCaseConstants.Type.Functional.getValue()) && StringUtils.equals(data.getMethod(), TestCaseConstants.Method.Auto.getValue())) {
stringBuilder.append(Translator.get("functional_method_tip") + "; ");
}
// if (StringUtils.equals(data.getType(), TestCaseConstants.Type.Functional.getValue()) && StringUtils.equals(data.getMethod(), TestCaseConstants.Method.Auto.getValue())) {
// stringBuilder.append(Translator.get("functional_method_tip") + "; ");
// }
if (!userIds.contains(data.getMaintainer())) {
stringBuilder.append(Translator.get("user_not_exists") + "" + data.getMaintainer() + "; ");

View File

@ -33,9 +33,7 @@ public class TestPlanApiCaseController {
@PostMapping("/relevance/list/{goPage}/{pageSize}")
public Pager<List<ApiTestCaseDTO>> relevanceList(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody ApiTestCaseRequest request) {
Page<Object> page = PageHelper.startPage(goPage, pageSize, true);
request.setWorkspaceId(SessionUtils.getCurrentWorkspaceId());
return PageUtils.setPageInfo(page, testPlanApiCaseService.relevanceList(request));
return testPlanApiCaseService.relevanceList(goPage, pageSize, request);
}
@GetMapping("/delete/{id}")

View File

@ -131,8 +131,8 @@ public class TestCaseService {
.andNodePathEqualTo(testCase.getNodePath())
.andTypeEqualTo(testCase.getType())
.andMaintainerEqualTo(testCase.getMaintainer())
.andPriorityEqualTo(testCase.getPriority())
.andMethodEqualTo(testCase.getMethod());
.andPriorityEqualTo(testCase.getPriority());
// .andMethodEqualTo(testCase.getMethod());
// if (StringUtils.isNotBlank(testCase.getNodeId())) {
// criteria.andNodeIdEqualTo(testCase.getTestId());
@ -432,7 +432,7 @@ public class TestCaseService {
List<TestCaseExcelData> list = new ArrayList<>();
StringBuilder path = new StringBuilder("");
List<String> types = TestCaseConstants.Type.getValues();
List<String> methods = TestCaseConstants.Method.getValues();
// List<String> methods = TestCaseConstants.Method.getValues();
SessionUser user = SessionUtils.getUser();
for (int i = 1; i <= 5; i++) {
TestCaseExcelData data = new TestCaseExcelData();
@ -442,11 +442,11 @@ public class TestCaseService {
data.setPriority("P" + i % 4);
String type = types.get(i % 3);
data.setType(type);
if (StringUtils.equals(TestCaseConstants.Type.Functional.getValue(), type)) {
data.setMethod(TestCaseConstants.Method.Manual.getValue());
} else {
data.setMethod(methods.get(i % 2));
}
// if (StringUtils.equals(TestCaseConstants.Type.Functional.getValue(), type)) {
// data.setMethod(TestCaseConstants.Method.Manual.getValue());
// } else {
// data.setMethod(methods.get(i % 2));
// }
data.setPrerequisite(Translator.get("preconditions_optional"));
data.setStepDesc("1. " + Translator.get("step_tip_separate") +
"\n2. " + Translator.get("step_tip_order") + "\n3. " + Translator.get("step_tip_optional"));
@ -461,7 +461,7 @@ public class TestCaseService {
explain.setName(Translator.get("do_not_modify_header_order"));
explain.setNodePath(Translator.get("module_created_automatically"));
explain.setType(Translator.get("options") + "functional、performance、api");
explain.setMethod(Translator.get("options") + "manual、auto");
// explain.setMethod(Translator.get("options") + "manual、auto");
explain.setPriority(Translator.get("options") + "P0、P1、P2、P3");
explain.setMaintainer(Translator.get("please_input_workspace_member"));
@ -483,7 +483,11 @@ public class TestCaseService {
private List<TestCaseExcelData> generateTestCaseExcel(TestCaseBatchRequest request) {
ServiceUtils.getSelectAllIds(request, request.getCondition(),
(query) -> extTestCaseMapper.selectIds(query));
List<OrderRequest> orderList = ServiceUtils.getDefaultOrder(request.getOrders());
QueryTestCaseRequest condition = request.getCondition();
List<OrderRequest> orderList = new ArrayList<>();
if (condition != null) {
orderList = ServiceUtils.getDefaultOrder(condition.getOrders());
}
OrderRequest order = new OrderRequest();
order.setName("sort");
order.setType("desc");
@ -499,10 +503,10 @@ public class TestCaseService {
data.setNodePath(t.getNodePath());
data.setPriority(t.getPriority());
data.setType(t.getType());
data.setMethod(t.getMethod());
// data.setMethod(t.getMethod());
data.setPrerequisite(t.getPrerequisite());
data.setTags(t.getTags());
if (t.getMethod().equals("manual")) {
if (StringUtils.equals(t.getMethod(), "manual") || StringUtils.isBlank(t.getMethod())) {
String steps = t.getSteps();
String setp = "";
setp = steps;
@ -530,19 +534,19 @@ public class TestCaseService {
result.setLength(0);
data.setRemark(t.getRemark());
} else if (t.getMethod().equals("auto") && t.getType().equals("api")) {
} else if ("auto".equals(t.getMethod()) && "api".equals(t.getType())) {
data.setStepDesc("");
data.setStepResult("");
if (t.getTestId() != null && t.getTestId().equals("other")) {
if (t.getTestId() != null && "other".equals(t.getTestId())) {
data.setRemark(t.getOtherTestName());
} else {
data.setRemark("[" + t.getApiName() + "]" + "\n" + t.getRemark());
}
} else if (t.getMethod().equals("auto") && t.getType().equals("performance")) {
} else if ("auto".equals(t.getMethod()) && "performance".equals(t.getType())) {
data.setStepDesc("");
data.setStepResult("");
if (t.getTestId() != null && t.getTestId().equals("other")) {
if (t.getTestId() != null && "other".equals(t.getTestId())) {
data.setRemark(t.getOtherTestName());
} else {
data.setRemark(t.getPerformName());

View File

@ -2,6 +2,8 @@ package io.metersphere.track.service;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import io.metersphere.api.dto.definition.ApiTestCaseDTO;
import io.metersphere.api.dto.definition.ApiTestCaseRequest;
import io.metersphere.api.dto.definition.RunDefinitionRequest;
@ -18,7 +20,10 @@ import io.metersphere.base.domain.TestPlanApiCase;
import io.metersphere.base.domain.TestPlanApiCaseExample;
import io.metersphere.base.mapper.TestPlanApiCaseMapper;
import io.metersphere.base.mapper.ext.ExtTestPlanApiCaseMapper;
import io.metersphere.commons.utils.PageUtils;
import io.metersphere.commons.utils.Pager;
import io.metersphere.commons.utils.ServiceUtils;
import io.metersphere.commons.utils.SessionUtils;
import io.metersphere.track.request.testcase.TestPlanApiCaseBatchRequest;
import org.apache.jmeter.testelement.TestElement;
import org.springframework.context.annotation.Lazy;
@ -61,13 +66,15 @@ public class TestPlanApiCaseService {
return extTestPlanApiCaseMapper.getExecResultByPlanId(plan);
}
public List<ApiTestCaseDTO> relevanceList(ApiTestCaseRequest request) {
public Pager<List<ApiTestCaseDTO>> relevanceList(int goPage, int pageSize, ApiTestCaseRequest request) {
List<String> ids = apiTestCaseService.selectIdsNotExistsInPlan(request.getProjectId(), request.getPlanId());
Page<Object> page = PageHelper.startPage(goPage, pageSize, true);
if (CollectionUtils.isEmpty(ids)) {
return new ArrayList<>();
return PageUtils.setPageInfo(page, new ArrayList<>());
}
request.setIds(ids);
return apiTestCaseService.listSimple(request);
request.setWorkspaceId(SessionUtils.getCurrentWorkspaceId());
return PageUtils.setPageInfo(page, apiTestCaseService.listSimple(request));
}
public int delete(String id) {

View File

@ -1,13 +1,19 @@
package io.metersphere.track.service;
import io.metersphere.api.dto.automation.ScenarioStatus;
import io.metersphere.base.domain.*;
import io.metersphere.base.mapper.*;
import io.metersphere.base.mapper.ext.ExtTestCaseMapper;
import io.metersphere.base.mapper.ext.ExtTestPlanTestCaseMapper;
import io.metersphere.commons.constants.TestPlanTestCaseStatus;
import io.metersphere.commons.utils.DateUtils;
import io.metersphere.commons.utils.MathUtils;
import io.metersphere.performance.base.ChartsData;
import io.metersphere.track.dto.TestPlanDTOWithMetric;
import io.metersphere.track.response.BugStatustics;
import io.metersphere.track.response.TestPlanBugCount;
import io.metersphere.track.response.TrackCountResult;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
@ -28,13 +34,13 @@ public class TrackService {
@Resource
private TestPlanMapper testPlanMapper;
@Resource
private TestPlanTestCaseMapper testPlanTestCaseMapper;
private ExtTestPlanTestCaseMapper extTestPlanTestCaseMapper;
@Resource
private TestPlanLoadCaseMapper testPlanLoadCaseMapper;
private TestPlanApiCaseService testPlanApiCaseService;
@Resource
private TestPlanApiCaseMapper testPlanApiCaseMapper;
private TestPlanScenarioCaseService testPlanScenarioCaseService;
@Resource
private TestPlanApiScenarioMapper testPlanApiScenarioMapper;
private TestPlanLoadCaseService testPlanLoadCaseService;
public List<TrackCountResult> countPriority(String projectId) {
return extTestCaseMapper.countPriority(projectId);
@ -132,11 +138,13 @@ public class TrackService {
int planBugSize = getPlanBugSize(plan.getId());
testPlanBug.setBugSize(planBugSize);
testPlanBug.setPassRage(getPlanPassRage(plan.getId(), planCaseSize));
double planPassRage = getPlanPassRage(plan.getId());
testPlanBug.setPassRage(planPassRage + "%");
list.add(testPlanBug);
totalBugSize += planBugSize;
totalCaseSize += planCaseSize;
}
bugStatustics.setList(list);
@ -156,13 +164,52 @@ public class TrackService {
return extTestCaseMapper.getTestPlanBug(planId);
}
private String getPlanPassRage(String planId, int totalSize) {
if (totalSize == 0) {
return "-";
}
int passSize = extTestCaseMapper.getTestPlanPassCase(planId);
float rage = (float) passSize * 100 / totalSize;
DecimalFormat df = new DecimalFormat("0.0");
return df.format(rage) + "%";
private double getPlanPassRage(String planId) {
TestPlanDTOWithMetric testPlan = new TestPlanDTOWithMetric();
testPlan.setTested(0);
testPlan.setPassed(0);
testPlan.setTotal(0);
List<String> functionalExecResults = extTestPlanTestCaseMapper.getExecResultByPlanId(planId);
functionalExecResults.forEach(item -> {
if (!StringUtils.equals(item, TestPlanTestCaseStatus.Prepare.name())
&& !StringUtils.equals(item, TestPlanTestCaseStatus.Underway.name())) {
testPlan.setTested(testPlan.getTested() + 1);
if (StringUtils.equals(item, TestPlanTestCaseStatus.Pass.name())) {
testPlan.setPassed(testPlan.getPassed() + 1);
}
}
});
List<String> apiExecResults = testPlanApiCaseService.getExecResultByPlanId(planId);
apiExecResults.forEach(item -> {
if (StringUtils.isNotBlank(item)) {
testPlan.setTested(testPlan.getTested() + 1);
if (StringUtils.equals(item, "success")) {
testPlan.setPassed(testPlan.getPassed() + 1);
}
}
});
List<String> scenarioExecResults = testPlanScenarioCaseService.getExecResultByPlanId(planId);
scenarioExecResults.forEach(item -> {
if (StringUtils.isNotBlank(item)) {
testPlan.setTested(testPlan.getTested() + 1);
if (StringUtils.equals(item, ScenarioStatus.Success.name())) {
testPlan.setPassed(testPlan.getPassed() + 1);
}
}
});
List<String> loadResults = testPlanLoadCaseService.getStatus(planId);
loadResults.forEach(item -> {
if (StringUtils.isNotBlank(item)) {
testPlan.setTested(testPlan.getTested() + 1);
if (StringUtils.equals(item, "success")) {
testPlan.setPassed(testPlan.getPassed() + 1);
}
}
});
return MathUtils.getPercentWithDecimal(testPlan.getTested() == 0 ? 0 : testPlan.getPassed() * 1.0 / testPlan.getTested());
}
}

View File

@ -175,3 +175,5 @@ CREATE TABLE IF NOT EXISTS `esb_api_params`
-- add execution_times testPlan
alter table test_plan
add execution_times int null;
alter table test_case modify method varchar(15) null comment 'Test case method type';

View File

@ -103,16 +103,16 @@ export default {
.active {
border: solid 1px #6d317c;
background-color: var(--color);
background-color: var(--primary_color);
color: #FFFFFF;
}
.case-button {
border-left: solid 1px var(--color);
border-left: solid 1px var(--primary_color);
}
.item{
border: solid 1px var(--color);
border: solid 1px var(--primary_color);
}
</style>

View File

@ -10,7 +10,7 @@
</template>
<search-list :current-project.sync="currentProject"/>
<el-divider/>
<el-menu-item :index="'/setting/project/create'">
<el-menu-item :index="'/setting/project/create'" v-permission="['test_manager','test_user']">
<font-awesome-icon :icon="['fa', 'plus']"/>
<span style="padding-left: 7px;">{{ $t("project.create") }}</span>
</el-menu-item>

View File

@ -10,7 +10,7 @@
@dataChange="changePlan"/>
</template>
<template v-slot:menu>
<el-menu v-if="isMenuShow" active-text-color="#6d317c" :default-active="activeIndex"
<el-menu v-if="isMenuShow" :active-text-color="color" :default-active="activeIndex"
class="el-menu-demo header-menu" mode="horizontal" @select="handleSelect">
<el-menu-item index="functional">功能测试用例</el-menu-item>
<el-menu-item index="api">接口测试用例</el-menu-item>
@ -71,6 +71,9 @@
computed: {
planId: function () {
return this.$route.params.planId;
},
color: function () {
return `var(--primary_color)`
}
},
watch: {

View File

@ -9,7 +9,7 @@
@dataChange="changeReview"/>
</template>
<template v-slot:menu>
<el-menu v-if="isMenuShow" active-text-color="#6d317c"
<el-menu v-if="isMenuShow" :active-text-color="color"
class="el-menu-demo header-menu" mode="horizontal" @select="handleSelect"
:default-active="activeIndex">
<el-menu-item index="functional">功能测试用例</el-menu-item>
@ -78,6 +78,9 @@ export default {
computed: {
reviewId: function () {
return this.$route.params.reviewId;
},
color: function () {
return `var(--primary_color)`
}
},
mounted() {

View File

@ -62,19 +62,19 @@ html,body {
/* <-- 表格拖拽表头调整宽度,在 t-bable 上添加 border 属性,并添加 adjust-table 类名 */
.adjust-table td {
border-right: 0;
border-right: 0 !important;
}
.adjust-table th {
border-right-color: white;
border-right-color: white !important;
}
.adjust-table {
border-color: white;
border-color: white !important;
}
.adjust-table:after {
background-color: white;
background-color: white !important;
}
.adjust-table th:not([class*="el-table-column--selection"]):hover:after {
@ -84,11 +84,11 @@ html,body {
right: 0;
height: 50%;
width: 2px;
background-color: #EBEEF5;
background-color: #EBEEF5 !important;
}
.adjust-table tr:hover td {
border-right: 0;
border-right: 0 !important;
}
/* 表格拖拽表头调整宽度 --> */