创建用例绑定测试

This commit is contained in:
chenjianxing 2020-05-28 09:47:24 +08:00
parent 48eafa2be0
commit bceade43a9
17 changed files with 313 additions and 54 deletions

View File

@ -7,7 +7,9 @@ import io.metersphere.api.dto.DeleteAPITestRequest;
import io.metersphere.api.dto.QueryAPITestRequest; import io.metersphere.api.dto.QueryAPITestRequest;
import io.metersphere.api.dto.SaveAPITestRequest; import io.metersphere.api.dto.SaveAPITestRequest;
import io.metersphere.api.service.APITestService; import io.metersphere.api.service.APITestService;
import io.metersphere.base.domain.ApiTest;
import io.metersphere.base.domain.ApiTestWithBLOBs; import io.metersphere.base.domain.ApiTestWithBLOBs;
import io.metersphere.base.domain.LoadTest;
import io.metersphere.commons.constants.RoleConstants; import io.metersphere.commons.constants.RoleConstants;
import io.metersphere.commons.utils.PageUtils; import io.metersphere.commons.utils.PageUtils;
import io.metersphere.commons.utils.Pager; import io.metersphere.commons.utils.Pager;
@ -44,6 +46,11 @@ public class APITestController {
return PageUtils.setPageInfo(page, apiTestService.list(request)); return PageUtils.setPageInfo(page, apiTestService.list(request));
} }
@GetMapping("/list/{projectId}")
public List<ApiTest> list(@PathVariable String projectId) {
return apiTestService.getApiTestByProjectId(projectId);
}
@PostMapping(value = "/create", consumes = {"multipart/form-data"}) @PostMapping(value = "/create", consumes = {"multipart/form-data"})
public void create(@RequestPart("request") SaveAPITestRequest request, @RequestPart(value = "files") List<MultipartFile> files) { public void create(@RequestPart("request") SaveAPITestRequest request, @RequestPart(value = "files") List<MultipartFile> files) {
apiTestService.create(request, files); apiTestService.create(request, files);

View File

@ -167,4 +167,7 @@ public class APITestService {
} }
} }
public List<ApiTest> getApiTestByProjectId(String projectId) {
return extApiTestMapper.getApiTestByProjectId(projectId);
}
} }

View File

@ -29,5 +29,7 @@ public class TestCase implements Serializable {
private Long updateTime; private Long updateTime;
private String testId;
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
} }

View File

@ -923,6 +923,76 @@ public class TestCaseExample {
addCriterion("update_time not between", value1, value2, "updateTime"); addCriterion("update_time not between", value1, value2, "updateTime");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andTestIdIsNull() {
addCriterion("test_id is null");
return (Criteria) this;
}
public Criteria andTestIdIsNotNull() {
addCriterion("test_id is not null");
return (Criteria) this;
}
public Criteria andTestIdEqualTo(String value) {
addCriterion("test_id =", value, "testId");
return (Criteria) this;
}
public Criteria andTestIdNotEqualTo(String value) {
addCriterion("test_id <>", value, "testId");
return (Criteria) this;
}
public Criteria andTestIdGreaterThan(String value) {
addCriterion("test_id >", value, "testId");
return (Criteria) this;
}
public Criteria andTestIdGreaterThanOrEqualTo(String value) {
addCriterion("test_id >=", value, "testId");
return (Criteria) this;
}
public Criteria andTestIdLessThan(String value) {
addCriterion("test_id <", value, "testId");
return (Criteria) this;
}
public Criteria andTestIdLessThanOrEqualTo(String value) {
addCriterion("test_id <=", value, "testId");
return (Criteria) this;
}
public Criteria andTestIdLike(String value) {
addCriterion("test_id like", value, "testId");
return (Criteria) this;
}
public Criteria andTestIdNotLike(String value) {
addCriterion("test_id not like", value, "testId");
return (Criteria) this;
}
public Criteria andTestIdIn(List<String> values) {
addCriterion("test_id in", values, "testId");
return (Criteria) this;
}
public Criteria andTestIdNotIn(List<String> values) {
addCriterion("test_id not in", values, "testId");
return (Criteria) this;
}
public Criteria andTestIdBetween(String value1, String value2) {
addCriterion("test_id between", value1, value2, "testId");
return (Criteria) this;
}
public Criteria andTestIdNotBetween(String value1, String value2) {
addCriterion("test_id not between", value1, value2, "testId");
return (Criteria) this;
}
} }
public static class Criteria extends GeneratedCriteria { public static class Criteria extends GeneratedCriteria {

View File

@ -21,5 +21,7 @@ public class TestPlanTestCase implements Serializable {
private Long updateTime; private Long updateTime;
private String reportId;
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
} }

View File

@ -643,6 +643,76 @@ public class TestPlanTestCaseExample {
addCriterion("update_time not between", value1, value2, "updateTime"); addCriterion("update_time not between", value1, value2, "updateTime");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andReportIdIsNull() {
addCriterion("report_id is null");
return (Criteria) this;
}
public Criteria andReportIdIsNotNull() {
addCriterion("report_id is not null");
return (Criteria) this;
}
public Criteria andReportIdEqualTo(String value) {
addCriterion("report_id =", value, "reportId");
return (Criteria) this;
}
public Criteria andReportIdNotEqualTo(String value) {
addCriterion("report_id <>", value, "reportId");
return (Criteria) this;
}
public Criteria andReportIdGreaterThan(String value) {
addCriterion("report_id >", value, "reportId");
return (Criteria) this;
}
public Criteria andReportIdGreaterThanOrEqualTo(String value) {
addCriterion("report_id >=", value, "reportId");
return (Criteria) this;
}
public Criteria andReportIdLessThan(String value) {
addCriterion("report_id <", value, "reportId");
return (Criteria) this;
}
public Criteria andReportIdLessThanOrEqualTo(String value) {
addCriterion("report_id <=", value, "reportId");
return (Criteria) this;
}
public Criteria andReportIdLike(String value) {
addCriterion("report_id like", value, "reportId");
return (Criteria) this;
}
public Criteria andReportIdNotLike(String value) {
addCriterion("report_id not like", value, "reportId");
return (Criteria) this;
}
public Criteria andReportIdIn(List<String> values) {
addCriterion("report_id in", values, "reportId");
return (Criteria) this;
}
public Criteria andReportIdNotIn(List<String> values) {
addCriterion("report_id not in", values, "reportId");
return (Criteria) this;
}
public Criteria andReportIdBetween(String value1, String value2) {
addCriterion("report_id between", value1, value2, "reportId");
return (Criteria) this;
}
public Criteria andReportIdNotBetween(String value1, String value2) {
addCriterion("report_id not between", value1, value2, "reportId");
return (Criteria) this;
}
} }
public static class Criteria extends GeneratedCriteria { public static class Criteria extends GeneratedCriteria {

View File

@ -14,6 +14,7 @@
<result column="prerequisite" jdbcType="VARCHAR" property="prerequisite" /> <result column="prerequisite" jdbcType="VARCHAR" property="prerequisite" />
<result column="create_time" jdbcType="BIGINT" property="createTime" /> <result column="create_time" jdbcType="BIGINT" property="createTime" />
<result column="update_time" jdbcType="BIGINT" property="updateTime" /> <result column="update_time" jdbcType="BIGINT" property="updateTime" />
<result column="test_id" jdbcType="VARCHAR" property="testId" />
</resultMap> </resultMap>
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="io.metersphere.base.domain.TestCaseWithBLOBs"> <resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="io.metersphere.base.domain.TestCaseWithBLOBs">
<result column="remark" jdbcType="LONGVARCHAR" property="remark" /> <result column="remark" jdbcType="LONGVARCHAR" property="remark" />
@ -79,7 +80,7 @@
</sql> </sql>
<sql id="Base_Column_List"> <sql id="Base_Column_List">
id, node_id, node_path, project_id, name, type, maintainer, priority, method, prerequisite, id, node_id, node_path, project_id, name, type, maintainer, priority, method, prerequisite,
create_time, update_time create_time, update_time, test_id
</sql> </sql>
<sql id="Blob_Column_List"> <sql id="Blob_Column_List">
remark, steps remark, steps
@ -137,12 +138,14 @@
project_id, name, type, project_id, name, type,
maintainer, priority, method, maintainer, priority, method,
prerequisite, create_time, update_time, prerequisite, create_time, update_time,
remark, steps) test_id, remark, steps
)
values (#{id,jdbcType=VARCHAR}, #{nodeId,jdbcType=VARCHAR}, #{nodePath,jdbcType=VARCHAR}, values (#{id,jdbcType=VARCHAR}, #{nodeId,jdbcType=VARCHAR}, #{nodePath,jdbcType=VARCHAR},
#{projectId,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{type,jdbcType=VARCHAR}, #{projectId,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{type,jdbcType=VARCHAR},
#{maintainer,jdbcType=VARCHAR}, #{priority,jdbcType=VARCHAR}, #{method,jdbcType=VARCHAR}, #{maintainer,jdbcType=VARCHAR}, #{priority,jdbcType=VARCHAR}, #{method,jdbcType=VARCHAR},
#{prerequisite,jdbcType=VARCHAR}, #{createTime,jdbcType=BIGINT}, #{updateTime,jdbcType=BIGINT}, #{prerequisite,jdbcType=VARCHAR}, #{createTime,jdbcType=BIGINT}, #{updateTime,jdbcType=BIGINT},
#{remark,jdbcType=LONGVARCHAR}, #{steps,jdbcType=LONGVARCHAR}) #{testId,jdbcType=VARCHAR}, #{remark,jdbcType=LONGVARCHAR}, #{steps,jdbcType=LONGVARCHAR}
)
</insert> </insert>
<insert id="insertSelective" parameterType="io.metersphere.base.domain.TestCaseWithBLOBs"> <insert id="insertSelective" parameterType="io.metersphere.base.domain.TestCaseWithBLOBs">
insert into test_case insert into test_case
@ -183,6 +186,9 @@
<if test="updateTime != null"> <if test="updateTime != null">
update_time, update_time,
</if> </if>
<if test="testId != null">
test_id,
</if>
<if test="remark != null"> <if test="remark != null">
remark, remark,
</if> </if>
@ -227,6 +233,9 @@
<if test="updateTime != null"> <if test="updateTime != null">
#{updateTime,jdbcType=BIGINT}, #{updateTime,jdbcType=BIGINT},
</if> </if>
<if test="testId != null">
#{testId,jdbcType=VARCHAR},
</if>
<if test="remark != null"> <if test="remark != null">
#{remark,jdbcType=LONGVARCHAR}, #{remark,jdbcType=LONGVARCHAR},
</if> </if>
@ -280,6 +289,9 @@
<if test="record.updateTime != null"> <if test="record.updateTime != null">
update_time = #{record.updateTime,jdbcType=BIGINT}, update_time = #{record.updateTime,jdbcType=BIGINT},
</if> </if>
<if test="record.testId != null">
test_id = #{record.testId,jdbcType=VARCHAR},
</if>
<if test="record.remark != null"> <if test="record.remark != null">
remark = #{record.remark,jdbcType=LONGVARCHAR}, remark = #{record.remark,jdbcType=LONGVARCHAR},
</if> </if>
@ -305,6 +317,7 @@
prerequisite = #{record.prerequisite,jdbcType=VARCHAR}, prerequisite = #{record.prerequisite,jdbcType=VARCHAR},
create_time = #{record.createTime,jdbcType=BIGINT}, create_time = #{record.createTime,jdbcType=BIGINT},
update_time = #{record.updateTime,jdbcType=BIGINT}, update_time = #{record.updateTime,jdbcType=BIGINT},
test_id = #{record.testId,jdbcType=VARCHAR},
remark = #{record.remark,jdbcType=LONGVARCHAR}, remark = #{record.remark,jdbcType=LONGVARCHAR},
steps = #{record.steps,jdbcType=LONGVARCHAR} steps = #{record.steps,jdbcType=LONGVARCHAR}
<if test="_parameter != null"> <if test="_parameter != null">
@ -324,7 +337,8 @@
method = #{record.method,jdbcType=VARCHAR}, method = #{record.method,jdbcType=VARCHAR},
prerequisite = #{record.prerequisite,jdbcType=VARCHAR}, prerequisite = #{record.prerequisite,jdbcType=VARCHAR},
create_time = #{record.createTime,jdbcType=BIGINT}, create_time = #{record.createTime,jdbcType=BIGINT},
update_time = #{record.updateTime,jdbcType=BIGINT} update_time = #{record.updateTime,jdbcType=BIGINT},
test_id = #{record.testId,jdbcType=VARCHAR}
<if test="_parameter != null"> <if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" /> <include refid="Update_By_Example_Where_Clause" />
</if> </if>
@ -365,6 +379,9 @@
<if test="updateTime != null"> <if test="updateTime != null">
update_time = #{updateTime,jdbcType=BIGINT}, update_time = #{updateTime,jdbcType=BIGINT},
</if> </if>
<if test="testId != null">
test_id = #{testId,jdbcType=VARCHAR},
</if>
<if test="remark != null"> <if test="remark != null">
remark = #{remark,jdbcType=LONGVARCHAR}, remark = #{remark,jdbcType=LONGVARCHAR},
</if> </if>
@ -387,6 +404,7 @@
prerequisite = #{prerequisite,jdbcType=VARCHAR}, prerequisite = #{prerequisite,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=BIGINT}, create_time = #{createTime,jdbcType=BIGINT},
update_time = #{updateTime,jdbcType=BIGINT}, update_time = #{updateTime,jdbcType=BIGINT},
test_id = #{testId,jdbcType=VARCHAR},
remark = #{remark,jdbcType=LONGVARCHAR}, remark = #{remark,jdbcType=LONGVARCHAR},
steps = #{steps,jdbcType=LONGVARCHAR} steps = #{steps,jdbcType=LONGVARCHAR}
where id = #{id,jdbcType=VARCHAR} where id = #{id,jdbcType=VARCHAR}
@ -403,7 +421,8 @@
method = #{method,jdbcType=VARCHAR}, method = #{method,jdbcType=VARCHAR},
prerequisite = #{prerequisite,jdbcType=VARCHAR}, prerequisite = #{prerequisite,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=BIGINT}, create_time = #{createTime,jdbcType=BIGINT},
update_time = #{updateTime,jdbcType=BIGINT} update_time = #{updateTime,jdbcType=BIGINT},
test_id = #{testId,jdbcType=VARCHAR}
where id = #{id,jdbcType=VARCHAR} where id = #{id,jdbcType=VARCHAR}
</update> </update>
</mapper> </mapper>

View File

@ -10,6 +10,7 @@
<result column="remark" jdbcType="VARCHAR" property="remark" /> <result column="remark" jdbcType="VARCHAR" property="remark" />
<result column="create_time" jdbcType="BIGINT" property="createTime" /> <result column="create_time" jdbcType="BIGINT" property="createTime" />
<result column="update_time" jdbcType="BIGINT" property="updateTime" /> <result column="update_time" jdbcType="BIGINT" property="updateTime" />
<result column="report_id" jdbcType="VARCHAR" property="reportId" />
</resultMap> </resultMap>
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="io.metersphere.base.domain.TestPlanTestCaseWithBLOBs"> <resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="io.metersphere.base.domain.TestPlanTestCaseWithBLOBs">
<result column="results" jdbcType="LONGVARCHAR" property="results" /> <result column="results" jdbcType="LONGVARCHAR" property="results" />
@ -74,7 +75,7 @@
</where> </where>
</sql> </sql>
<sql id="Base_Column_List"> <sql id="Base_Column_List">
id, plan_id, case_id, executor, status, remark, create_time, update_time id, plan_id, case_id, executor, status, remark, create_time, update_time, report_id
</sql> </sql>
<sql id="Blob_Column_List"> <sql id="Blob_Column_List">
results, issues results, issues
@ -130,12 +131,12 @@
<insert id="insert" parameterType="io.metersphere.base.domain.TestPlanTestCaseWithBLOBs"> <insert id="insert" parameterType="io.metersphere.base.domain.TestPlanTestCaseWithBLOBs">
insert into test_plan_test_case (id, plan_id, case_id, insert into test_plan_test_case (id, plan_id, case_id,
executor, status, remark, executor, status, remark,
create_time, update_time, results, create_time, update_time, report_id,
issues) results, issues)
values (#{id,jdbcType=VARCHAR}, #{planId,jdbcType=VARCHAR}, #{caseId,jdbcType=VARCHAR}, values (#{id,jdbcType=VARCHAR}, #{planId,jdbcType=VARCHAR}, #{caseId,jdbcType=VARCHAR},
#{executor,jdbcType=VARCHAR}, #{status,jdbcType=VARCHAR}, #{remark,jdbcType=VARCHAR}, #{executor,jdbcType=VARCHAR}, #{status,jdbcType=VARCHAR}, #{remark,jdbcType=VARCHAR},
#{createTime,jdbcType=BIGINT}, #{updateTime,jdbcType=BIGINT}, #{results,jdbcType=LONGVARCHAR}, #{createTime,jdbcType=BIGINT}, #{updateTime,jdbcType=BIGINT}, #{reportId,jdbcType=VARCHAR},
#{issues,jdbcType=LONGVARCHAR}) #{results,jdbcType=LONGVARCHAR}, #{issues,jdbcType=LONGVARCHAR})
</insert> </insert>
<insert id="insertSelective" parameterType="io.metersphere.base.domain.TestPlanTestCaseWithBLOBs"> <insert id="insertSelective" parameterType="io.metersphere.base.domain.TestPlanTestCaseWithBLOBs">
insert into test_plan_test_case insert into test_plan_test_case
@ -164,6 +165,9 @@
<if test="updateTime != null"> <if test="updateTime != null">
update_time, update_time,
</if> </if>
<if test="reportId != null">
report_id,
</if>
<if test="results != null"> <if test="results != null">
results, results,
</if> </if>
@ -196,6 +200,9 @@
<if test="updateTime != null"> <if test="updateTime != null">
#{updateTime,jdbcType=BIGINT}, #{updateTime,jdbcType=BIGINT},
</if> </if>
<if test="reportId != null">
#{reportId,jdbcType=VARCHAR},
</if>
<if test="results != null"> <if test="results != null">
#{results,jdbcType=LONGVARCHAR}, #{results,jdbcType=LONGVARCHAR},
</if> </if>
@ -237,6 +244,9 @@
<if test="record.updateTime != null"> <if test="record.updateTime != null">
update_time = #{record.updateTime,jdbcType=BIGINT}, update_time = #{record.updateTime,jdbcType=BIGINT},
</if> </if>
<if test="record.reportId != null">
report_id = #{record.reportId,jdbcType=VARCHAR},
</if>
<if test="record.results != null"> <if test="record.results != null">
results = #{record.results,jdbcType=LONGVARCHAR}, results = #{record.results,jdbcType=LONGVARCHAR},
</if> </if>
@ -258,6 +268,7 @@
remark = #{record.remark,jdbcType=VARCHAR}, remark = #{record.remark,jdbcType=VARCHAR},
create_time = #{record.createTime,jdbcType=BIGINT}, create_time = #{record.createTime,jdbcType=BIGINT},
update_time = #{record.updateTime,jdbcType=BIGINT}, update_time = #{record.updateTime,jdbcType=BIGINT},
report_id = #{record.reportId,jdbcType=VARCHAR},
results = #{record.results,jdbcType=LONGVARCHAR}, results = #{record.results,jdbcType=LONGVARCHAR},
issues = #{record.issues,jdbcType=LONGVARCHAR} issues = #{record.issues,jdbcType=LONGVARCHAR}
<if test="_parameter != null"> <if test="_parameter != null">
@ -273,7 +284,8 @@
status = #{record.status,jdbcType=VARCHAR}, status = #{record.status,jdbcType=VARCHAR},
remark = #{record.remark,jdbcType=VARCHAR}, remark = #{record.remark,jdbcType=VARCHAR},
create_time = #{record.createTime,jdbcType=BIGINT}, create_time = #{record.createTime,jdbcType=BIGINT},
update_time = #{record.updateTime,jdbcType=BIGINT} update_time = #{record.updateTime,jdbcType=BIGINT},
report_id = #{record.reportId,jdbcType=VARCHAR}
<if test="_parameter != null"> <if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" /> <include refid="Update_By_Example_Where_Clause" />
</if> </if>
@ -302,6 +314,9 @@
<if test="updateTime != null"> <if test="updateTime != null">
update_time = #{updateTime,jdbcType=BIGINT}, update_time = #{updateTime,jdbcType=BIGINT},
</if> </if>
<if test="reportId != null">
report_id = #{reportId,jdbcType=VARCHAR},
</if>
<if test="results != null"> <if test="results != null">
results = #{results,jdbcType=LONGVARCHAR}, results = #{results,jdbcType=LONGVARCHAR},
</if> </if>
@ -320,6 +335,7 @@
remark = #{remark,jdbcType=VARCHAR}, remark = #{remark,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=BIGINT}, create_time = #{createTime,jdbcType=BIGINT},
update_time = #{updateTime,jdbcType=BIGINT}, update_time = #{updateTime,jdbcType=BIGINT},
report_id = #{reportId,jdbcType=VARCHAR},
results = #{results,jdbcType=LONGVARCHAR}, results = #{results,jdbcType=LONGVARCHAR},
issues = #{issues,jdbcType=LONGVARCHAR} issues = #{issues,jdbcType=LONGVARCHAR}
where id = #{id,jdbcType=VARCHAR} where id = #{id,jdbcType=VARCHAR}
@ -332,7 +348,8 @@
status = #{status,jdbcType=VARCHAR}, status = #{status,jdbcType=VARCHAR},
remark = #{remark,jdbcType=VARCHAR}, remark = #{remark,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=BIGINT}, create_time = #{createTime,jdbcType=BIGINT},
update_time = #{updateTime,jdbcType=BIGINT} update_time = #{updateTime,jdbcType=BIGINT},
report_id = #{reportId,jdbcType=VARCHAR}
where id = #{id,jdbcType=VARCHAR} where id = #{id,jdbcType=VARCHAR}
</update> </update>
</mapper> </mapper>

View File

@ -2,6 +2,7 @@ package io.metersphere.base.mapper.ext;
import io.metersphere.api.dto.APITestResult; import io.metersphere.api.dto.APITestResult;
import io.metersphere.api.dto.QueryAPITestRequest; import io.metersphere.api.dto.QueryAPITestRequest;
import io.metersphere.base.domain.ApiTest;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.util.List; import java.util.List;
@ -10,4 +11,6 @@ public interface ExtApiTestMapper {
List<APITestResult> list(@Param("request") QueryAPITestRequest request); List<APITestResult> list(@Param("request") QueryAPITestRequest request);
Long countByProjectId(String projectId); Long countByProjectId(String projectId);
List<ApiTest> getApiTestByProjectId(String projectId);
} }

View File

@ -31,7 +31,12 @@
</select> </select>
<select id="countByProjectId" resultType="java.lang.Long"> <select id="countByProjectId" resultType="java.lang.Long">
select count(id) from api_test select count(id) from api_test
where project_id = #{projectId}; where project_id = #{projectId}
</select>
<select id="getApiTestByProjectId" resultType="io.metersphere.base.domain.ApiTest">
select id,name
from api_test
where project_id = #{projectId}
</select> </select>
</mapper> </mapper>

View File

@ -1,5 +1,6 @@
package io.metersphere.base.mapper.ext; package io.metersphere.base.mapper.ext;
import io.metersphere.base.domain.LoadTest;
import io.metersphere.track.request.testplan.QueryTestPlanRequest; import io.metersphere.track.request.testplan.QueryTestPlanRequest;
import io.metersphere.dto.LoadTestDTO; import io.metersphere.dto.LoadTestDTO;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
@ -10,4 +11,6 @@ public interface ExtLoadTestMapper {
List<LoadTestDTO> list(@Param("request") QueryTestPlanRequest params); List<LoadTestDTO> list(@Param("request") QueryTestPlanRequest params);
Long countByProjectId(String projectId); Long countByProjectId(String projectId);
List<LoadTest> getLoadTestByProjectId(String projectId);
} }

View File

@ -31,5 +31,10 @@
select count(id) from load_test select count(id) from load_test
where project_id = #{projectId}; where project_id = #{projectId};
</select> </select>
<select id="getLoadTestByProjectId" resultType="io.metersphere.base.domain.LoadTest">
select id,name
from load_test
where project_id = #{projectId};
</select>
</mapper> </mapper>

View File

@ -3,6 +3,7 @@ package io.metersphere.performance.controller;
import com.github.pagehelper.Page; import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import io.metersphere.base.domain.FileMetadata; import io.metersphere.base.domain.FileMetadata;
import io.metersphere.base.domain.LoadTest;
import io.metersphere.commons.constants.RoleConstants; import io.metersphere.commons.constants.RoleConstants;
import io.metersphere.commons.utils.PageUtils; import io.metersphere.commons.utils.PageUtils;
import io.metersphere.commons.utils.Pager; import io.metersphere.commons.utils.Pager;
@ -48,6 +49,11 @@ public class PerformanceTestController {
return PageUtils.setPageInfo(page, performanceTestService.list(request)); return PageUtils.setPageInfo(page, performanceTestService.list(request));
} }
@GetMapping("/list/{projectId}")
public List<LoadTest> list(@PathVariable String projectId) {
return performanceTestService.getLoadTestByProjectId(projectId);
}
@PostMapping(value = "/save", consumes = {"multipart/form-data"}) @PostMapping(value = "/save", consumes = {"multipart/form-data"})
public String save( public String save(
@RequestPart("request") SaveTestPlanRequest request, @RequestPart("request") SaveTestPlanRequest request,

View File

@ -280,4 +280,7 @@ public class PerformanceTestService {
return extLoadTestReportMapper.selectDashboardTests(workspaceId, startTimestamp); return extLoadTestReportMapper.selectDashboardTests(workspaceId, startTimestamp);
} }
public List<LoadTest> getLoadTestByProjectId(String projectId) {
return extLoadTestMapper.getLoadTestByProjectId(projectId);
}
} }

View File

@ -286,6 +286,7 @@ CREATE TABLE IF NOT EXISTS `test_case_node` (
CREATE TABLE IF NOT EXISTS `test_case` ( CREATE TABLE IF NOT EXISTS `test_case` (
`id` varchar(50) NOT NULL COMMENT 'Test case ID', `id` varchar(50) NOT NULL COMMENT 'Test case ID',
`node_id` varchar(50) NOT NULL COMMENT 'Node ID this case belongs to', `node_id` varchar(50) NOT NULL COMMENT 'Node ID this case belongs to',
`test_id` varchar(50) DEFAULT NULL COMMENT 'Test ID relation to',
`node_path` varchar(50) NOT NULL COMMENT 'Node path this case belongs to', `node_path` varchar(50) NOT NULL COMMENT 'Node path this case belongs to',
`project_id` varchar(50) NOT NULL COMMENT 'Project ID this test belongs to', `project_id` varchar(50) NOT NULL COMMENT 'Project ID this test belongs to',
`name` varchar(64) NOT NULL COMMENT 'Case name', `name` varchar(64) NOT NULL COMMENT 'Case name',
@ -309,6 +310,7 @@ CREATE TABLE IF NOT EXISTS `test_plan_test_case` (
`id` varchar(50) NOT NULL COMMENT 'ID', `id` varchar(50) NOT NULL COMMENT 'ID',
`plan_id` varchar(50) NOT NULL COMMENT 'Plan ID relation to', `plan_id` varchar(50) NOT NULL COMMENT 'Plan ID relation to',
`case_id` varchar(50) NOT NULL COMMENT 'Case ID relation to', `case_id` varchar(50) NOT NULL COMMENT 'Case ID relation to',
`report_id` varchar(50) DEFAULT NULL COMMENT 'Test report ID relation to',
`executor` varchar(64) NOT NULL COMMENT 'Test case executor', `executor` varchar(64) NOT NULL COMMENT 'Test case executor',
`status` varchar(15) NULL COMMENT 'Test case status', `status` varchar(15) NULL COMMENT 'Test case status',
`results` longtext COMMENT 'Test case result', `results` longtext COMMENT 'Test case result',

View File

@ -59,8 +59,8 @@
<!--要生成的数据库表 --> <!--要生成的数据库表 -->
<table tableName="load_test_report"/> <table tableName="test_plan_test_case"/>
<table tableName="load_test"/> <table tableName="test_case"/>
</context> </context>
</generatorConfiguration> </generatorConfiguration>

View File

@ -64,7 +64,7 @@
<el-row> <el-row>
<el-col :span="10" :offset="1"> <el-col :span="10" :offset="1">
<el-form-item :label="$t('test_track.case.type')" :label-width="formLabelWidth" prop="type"> <el-form-item :label="$t('test_track.case.type')" :label-width="formLabelWidth" prop="type">
<el-select :disabled="readOnly" v-model="form.type" :placeholder="$t('test_track.case.input_type')"> <el-select @change="typeChange" :disabled="readOnly" v-model="form.type" :placeholder="$t('test_track.case.input_type')">
<el-option :label="$t('commons.functional')" value="functional"></el-option> <el-option :label="$t('commons.functional')" value="functional"></el-option>
<el-option :label="$t('commons.performance')" value="performance"></el-option> <el-option :label="$t('commons.performance')" value="performance"></el-option>
<el-option :label="$t('commons.api')" value="api"></el-option> <el-option :label="$t('commons.api')" value="api"></el-option>
@ -81,6 +81,21 @@
</el-col> </el-col>
</el-row> </el-row>
<el-row v-if="form.method && form.method == 'auto'">
<el-col :span="10" :offset="1">
<el-form-item :label="'关联测试'" :label-width="formLabelWidth" prop="testId">
<el-select filterable :disabled="readOnly" v-model="form.testId" :placeholder="$t('test_track.case.input_type')">
<el-option
v-for="item in testOptions"
:key="item.id"
:label="item.name"
:value="item.id">
</el-option>
</el-select>
</el-form-item>
</el-col>
</el-row>
<el-row style="margin-top: 15px;"> <el-row style="margin-top: 15px;">
<el-col :offset="2">{{$t('test_track.case.prerequisite')}}:</el-col> <el-col :offset="2">{{$t('test_track.case.prerequisite')}}:</el-col>
</el-row> </el-row>
@ -213,6 +228,7 @@
type: '', type: '',
method: '', method: '',
prerequisite: '', prerequisite: '',
testId: '',
steps: [{ steps: [{
num: 1 , num: 1 ,
desc: '', desc: '',
@ -222,6 +238,7 @@
}, },
moduleOptions: [], moduleOptions: [],
maintainerOptions: [], maintainerOptions: [],
testOptions: [],
workspaceId: '', workspaceId: '',
rules:{ rules:{
name :[ name :[
@ -232,6 +249,7 @@
maintainer :[{required: true, message: this.$t('test_track.case.input_maintainer'), trigger: 'change'}], maintainer :[{required: true, message: this.$t('test_track.case.input_maintainer'), trigger: 'change'}],
priority :[{required: true, message: this.$t('test_track.case.input_priority'), trigger: 'change'}], priority :[{required: true, message: this.$t('test_track.case.input_priority'), trigger: 'change'}],
type :[{required: true, message: this.$t('test_track.case.input_type'), trigger: 'change'}], type :[{required: true, message: this.$t('test_track.case.input_type'), trigger: 'change'}],
testId :[{required: true, message: '请选择测试', trigger: 'change'}],
method :[{required: true, message: this.$t('test_track.case.input_method'), trigger: 'change'}], method :[{required: true, message: this.$t('test_track.case.input_method'), trigger: 'change'}],
prerequisite :[{ max: 300, message: this.$t('test_track.length_less_than') + '300', trigger: 'blur'}], prerequisite :[{ max: 300, message: this.$t('test_track.length_less_than') + '300', trigger: 'blur'}],
remark :[{ max: 300, message: this.$t('test_track.length_less_than') + '300', trigger: 'blur'}] remark :[{ max: 300, message: this.$t('test_track.length_less_than') + '300', trigger: 'blur'}]
@ -258,6 +276,9 @@
}, },
mounted() { mounted() {
this.getSelectOptions(); this.getSelectOptions();
},
watch: {
}, },
methods: { methods: {
open(testCase) { open(testCase) {
@ -315,35 +336,8 @@
saveCase(){ saveCase(){
this.$refs['caseFrom'].validate((valid) => { this.$refs['caseFrom'].validate((valid) => {
if (valid) { if (valid) {
let param = {}; let param = this.buildParam();
Object.assign(param, this.form); if (this.validate(param)) {
for (let i = 0; i < param.steps.length; i++){
if ((param.steps[i].desc && param.steps[i].desc.length > 300) ||
(param.steps[i].result && param.steps[i].result.length > 300)) {
this.$warning(this.$t('test_track.case.step_desc') + ","
+ this.$t('test_track.case.expected_results') + this.$t('test_track.length_less_than') + '300');
return;
}
}
param.steps = JSON.stringify(this.form.steps);
param.nodeId = this.form.module;
this.moduleOptions.forEach(item => {
if(this.form.module === item.id){
param.nodePath = item.path;
}
});
if (this.currentProject) {
param.projectId = this.currentProject.id;
}
param.name = param.name.trim();
if (param.name == '') {
this.$warning(this.$t('test_track.case.input_name'));
return;
}
this.result = this.$post('/test/case/' + this.operationType, param, () => { this.result = this.$post('/test/case/' + this.operationType, param, () => {
this.$success(this.$t('commons.save_success')); this.$success(this.$t('commons.save_success'));
if (this.operationType == 'add' && this.isCreateContinue) { if (this.operationType == 'add' && this.isCreateContinue) {
@ -353,11 +347,50 @@
this.dialogFormVisible = false; this.dialogFormVisible = false;
this.$emit("refresh"); this.$emit("refresh");
}); });
}
} else { } else {
return false; return false;
} }
}); });
}, },
buildParam() {
let param = {};
Object.assign(param, this.form);
param.steps = JSON.stringify(this.form.steps);
param.nodeId = this.form.module;
this.moduleOptions.forEach(item => {
if(this.form.module === item.id){
param.nodePath = item.path;
}
});
if (this.currentProject) {
param.projectId = this.currentProject.id;
}
param.name = param.name.trim();
if (param.method != 'auto') {
param.testId = null;
}
return param;
},
validate(param) {
for (let i = 0; i < param.steps.length; i++){
if ((param.steps[i].desc && param.steps[i].desc.length > 300) ||
(param.steps[i].result && param.steps[i].result.length > 300)) {
this.$warning(this.$t('test_track.case.step_desc') + ","
+ this.$t('test_track.case.expected_results') + this.$t('test_track.length_less_than') + '300');
return false;
}
}
if (param.name == '') {
this.$warning(this.$t('test_track.case.input_name'));
return false;
}
return true;
},
typeChange() {
this.form.testId = '';
this.getTestOptions()
},
getModuleOptions() { getModuleOptions() {
let moduleOptions = []; let moduleOptions = [];
this.treeNodes.forEach(node => { this.treeNodes.forEach(node => {
@ -371,9 +404,18 @@
this.maintainerOptions = response.data; this.maintainerOptions = response.data;
}); });
}, },
getTestOptions() {
this.testOptions = [];
if (this.currentProject && this.form.type != '' && this.form.type != 'functional') {
this.$get('/' + this.form.type + '/list/' + this.currentProject.id, response => {
this.testOptions = response.data;
});
}
},
getSelectOptions() { getSelectOptions() {
this.getModuleOptions(); this.getModuleOptions();
this.getMaintainerOptions(); this.getMaintainerOptions();
this.getTestOptions();
}, },
buildNodePath(node, option, moduleOptions) { buildNodePath(node, option, moduleOptions) {
// //