fix(测试跟踪): 修复接口调用没有关联可执行用例测试计划执行时没有提示的缺陷 (#16502)
--bug=1015449 --user=王孝刚 [测试计划]github#16371测试计划里只包含功能用例,在页面无法执行,但是调用API可以执行,且可正常生成报告,报告里无任何信息 https://www.tapd.cn/55049933/s/1214889 Co-authored-by: wxg0103 <727495428@qq.com>
This commit is contained in:
parent
dc17466990
commit
08519bc6e0
|
@ -20,7 +20,7 @@ public interface ExtTestPlanApiCaseMapper {
|
|||
|
||||
List<String> getIdsByPlanId(String planId);
|
||||
|
||||
List<String> getNotRelevanceCaseIds(@Param("planId")String planId, @Param("relevanceProjectIds")List<String> relevanceProjectIds);
|
||||
List<String> getNotRelevanceCaseIds(@Param("planId") String planId, @Param("relevanceProjectIds") List<String> relevanceProjectIds);
|
||||
|
||||
List<String> getStatusByTestPlanId(String id);
|
||||
|
||||
|
@ -36,14 +36,17 @@ public interface ExtTestPlanApiCaseMapper {
|
|||
|
||||
List<TestPlanFailureApiDTO> getFailureList(@Param("planId") String planId, @Param("status") String status);
|
||||
|
||||
List<TestPlanFailureApiDTO> getFailureListByIds(@Param("ids") Collection<String> caseIdList,@Param("status") String status);
|
||||
List<TestPlanFailureApiDTO> getFailureListByIds(@Param("ids") Collection<String> caseIdList, @Param("status") String status);
|
||||
|
||||
List<String> selectPlanIds();
|
||||
|
||||
List<String> getIdsOrderByUpdateTime(@Param("planId") String planId);
|
||||
|
||||
Long getPreOrder(@Param("planId")String planId, @Param("baseOrder") Long baseOrder);
|
||||
Long getPreOrder(@Param("planId") String planId, @Param("baseOrder") Long baseOrder);
|
||||
|
||||
Long getLastOrder(@Param("planId") String planId, @Param("baseOrder") Long baseOrder);
|
||||
|
||||
List<TestPlanApiCase> selectByIdsAndStatusIsNotTrash(@Param("ids") List<String> ids);
|
||||
|
||||
Long getLastOrder(@Param("planId")String planId, @Param("baseOrder") Long baseOrder);
|
||||
}
|
||||
|
||||
|
|
|
@ -3,368 +3,410 @@
|
|||
<mapper namespace="io.metersphere.base.mapper.ext.ExtTestPlanApiCaseMapper">
|
||||
|
||||
|
||||
<insert id="insertIfNotExists" parameterType="io.metersphere.base.domain.TestPlanApiCase">
|
||||
INSERT INTO test_plan_api_case(id, test_plan_id, api_case_id, environment_id, create_time, update_time, create_user, `order`)
|
||||
SELECT #{request.id}, #{request.testPlanId}, #{request.apiCaseId}, #{request.environmentId}, #{request.createTime}, #{request.updateTime}, #{request.createUser}, #{request.order}
|
||||
FROM DUAL
|
||||
WHERE NOT EXISTS(
|
||||
SELECT id FROM
|
||||
test_plan_api_case
|
||||
WHERE test_plan_id = #{request.testPlanId} and api_case_id = #{request.apiCaseId}
|
||||
)
|
||||
</insert>
|
||||
<select id="getApiTestCaseById" resultType="io.metersphere.base.domain.ApiTestCaseWithBLOBs">
|
||||
SELECT t.* FROM api_test_case t
|
||||
INNER JOIN test_plan_api_case tpac ON t.id = tpac.api_case_id
|
||||
WHERE tpac.id = #{0}
|
||||
</select>
|
||||
<select id="getApiTestCaseIdById" resultType="java.lang.String">
|
||||
SELECT api_case_id FROM test_plan_api_case t WHERE id = #{0}
|
||||
</select>
|
||||
<select id="selectLegalDataByTestPlanId" resultType="io.metersphere.base.domain.TestPlanApiCase">
|
||||
SELECT t.* FROM test_plan_api_case t WHERE t.test_plan_id = #{0}
|
||||
AND t.api_case_id IN (
|
||||
SELECT id FROM api_test_case WHERE status IS NULL OR status != 'Trash'
|
||||
)
|
||||
ORDER BY `order` DESC
|
||||
</select>
|
||||
<select id="list" resultType="io.metersphere.api.dto.definition.TestPlanApiCaseDTO">
|
||||
select
|
||||
t.id,
|
||||
t.environment_id,
|
||||
(
|
||||
SELECT
|
||||
NAME
|
||||
FROM
|
||||
api_test_environment
|
||||
WHERE
|
||||
id = t.environment_id
|
||||
) AS environment_name,
|
||||
t.create_time,
|
||||
t.update_time,
|
||||
c.id AS case_id,
|
||||
c.project_id,
|
||||
c.name,
|
||||
c.api_definition_id,
|
||||
c.priority,
|
||||
c.description,
|
||||
c.create_user_id,
|
||||
c.update_user_id,
|
||||
c.num,
|
||||
c.tags,
|
||||
c.create_user_id as create_user,
|
||||
a.module_id,
|
||||
a.path,
|
||||
a.protocol,
|
||||
t.status execResult,
|
||||
a.user_id,
|
||||
a.version_id versionId
|
||||
from
|
||||
test_plan_api_case t
|
||||
inner join
|
||||
api_test_case c
|
||||
on t.api_case_id = c.id
|
||||
<if test="request.planId != null and request.planId!=''">
|
||||
and t.test_plan_id = #{request.planId}
|
||||
</if>
|
||||
inner join
|
||||
api_definition a
|
||||
on
|
||||
c.api_definition_id = a.id
|
||||
where 1
|
||||
<if test="request.protocol != null and request.protocol!=''">
|
||||
and a.protocol = #{request.protocol}
|
||||
</if>
|
||||
<choose>
|
||||
<when test="request.status == 'Trash'">
|
||||
and c.status = 'Trash'
|
||||
</when>
|
||||
<when test="request.status == null">
|
||||
and (c.status IS NULL or c.status != 'Trash')
|
||||
</when>
|
||||
<when test="request.status == ''">
|
||||
and (c.status IS NULL or c.status != 'Trash')
|
||||
</when>
|
||||
<when test="request.status == 'running'">
|
||||
and t.status IS NULL
|
||||
</when>
|
||||
<otherwise>
|
||||
and t.status = #{request.status}
|
||||
</otherwise>
|
||||
</choose>
|
||||
<if test="request.ids != null and request.ids.size() > 0">
|
||||
<if test="request.projectId != null and request.projectId!=''">
|
||||
and a.projectId = #{request.projectId}
|
||||
</if>
|
||||
and t.id in
|
||||
<foreach collection="request.ids" item="caseId" separator="," open="(" close=")">
|
||||
#{caseId}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="request.name != null and request.name!=''">
|
||||
and (c.name like CONCAT('%', #{request.name},'%')
|
||||
or c.tags like CONCAT('%', #{request.name},'%')
|
||||
or c.num like CONCAT('%', #{request.name},'%')
|
||||
)
|
||||
</if>
|
||||
<if test="request.moduleIds != null and request.moduleIds.size() > 0">
|
||||
and a.module_id in
|
||||
<foreach collection="request.moduleIds" item="nodeId" separator="," open="(" close=")">
|
||||
#{nodeId}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="request.filters != null and request.filters.size() > 0">
|
||||
<foreach collection="request.filters.entrySet()" index="key" item="values">
|
||||
<if test="values != null and values.size() > 0">
|
||||
<choose>
|
||||
<when test="key == 'priority'">
|
||||
and c.priority in
|
||||
<foreach collection="values" item="value" separator="," open="(" close=")">
|
||||
#{value}
|
||||
</foreach>
|
||||
</when>
|
||||
<when test="key == 'user_id'">
|
||||
and c.create_user_id in
|
||||
<foreach collection="values" item="value" separator="," open="(" close=")">
|
||||
#{value}
|
||||
</foreach>
|
||||
</when>
|
||||
<when test="key == 'priority'">
|
||||
and a.priority in
|
||||
<foreach collection="values" item="value" separator="," open="(" close=")">
|
||||
#{value}
|
||||
</foreach>
|
||||
</when>
|
||||
<when test="key == 'version_id'">
|
||||
and a.version_id in
|
||||
<foreach collection="values" item="value" separator="," open="(" close=")">
|
||||
#{value}
|
||||
</foreach>
|
||||
</when>
|
||||
</choose>
|
||||
<insert id="insertIfNotExists" parameterType="io.metersphere.base.domain.TestPlanApiCase">
|
||||
INSERT INTO test_plan_api_case(id, test_plan_id, api_case_id, environment_id, create_time, update_time,
|
||||
create_user, `order`)
|
||||
SELECT #{request.id},
|
||||
#{request.testPlanId},
|
||||
#{request.apiCaseId},
|
||||
#{request.environmentId},
|
||||
#{request.createTime},
|
||||
#{request.updateTime},
|
||||
#{request.createUser},
|
||||
#{request.order}
|
||||
FROM DUAL
|
||||
WHERE NOT EXISTS(
|
||||
SELECT id
|
||||
FROM test_plan_api_case
|
||||
WHERE test_plan_id = #{request.testPlanId}
|
||||
and api_case_id = #{request.apiCaseId}
|
||||
)
|
||||
</insert>
|
||||
<select id="getApiTestCaseById" resultType="io.metersphere.base.domain.ApiTestCaseWithBLOBs">
|
||||
SELECT t.*
|
||||
FROM api_test_case t
|
||||
INNER JOIN test_plan_api_case tpac ON t.id = tpac.api_case_id
|
||||
WHERE tpac.id = #{0}
|
||||
</select>
|
||||
<select id="getApiTestCaseIdById" resultType="java.lang.String">
|
||||
SELECT api_case_id
|
||||
FROM test_plan_api_case t
|
||||
WHERE id = #{0}
|
||||
</select>
|
||||
<select id="selectLegalDataByTestPlanId" resultType="io.metersphere.base.domain.TestPlanApiCase">
|
||||
SELECT t.*
|
||||
FROM test_plan_api_case t
|
||||
WHERE t.test_plan_id = #{0}
|
||||
AND t.api_case_id IN (
|
||||
SELECT id
|
||||
FROM api_test_case
|
||||
WHERE status IS NULL
|
||||
OR status
|
||||
!= 'Trash'
|
||||
)
|
||||
ORDER BY `order` DESC
|
||||
</select>
|
||||
<select id="list" resultType="io.metersphere.api.dto.definition.TestPlanApiCaseDTO">
|
||||
select
|
||||
t.id,
|
||||
t.environment_id,
|
||||
(
|
||||
SELECT
|
||||
NAME
|
||||
FROM
|
||||
api_test_environment
|
||||
WHERE
|
||||
id = t.environment_id
|
||||
) AS environment_name,
|
||||
t.create_time,
|
||||
t.update_time,
|
||||
c.id AS case_id,
|
||||
c.project_id,
|
||||
c.name,
|
||||
c.api_definition_id,
|
||||
c.priority,
|
||||
c.description,
|
||||
c.create_user_id,
|
||||
c.update_user_id,
|
||||
c.num,
|
||||
c.tags,
|
||||
c.create_user_id as create_user,
|
||||
a.module_id,
|
||||
a.path,
|
||||
a.protocol,
|
||||
t.status execResult,
|
||||
a.user_id,
|
||||
a.version_id versionId
|
||||
from
|
||||
test_plan_api_case t
|
||||
inner join
|
||||
api_test_case c
|
||||
on t.api_case_id = c.id
|
||||
<if test="request.planId != null and request.planId!=''">
|
||||
and t.test_plan_id = #{request.planId}
|
||||
</if>
|
||||
</foreach>
|
||||
</if>
|
||||
<include refid="queryVersionCondition">
|
||||
<property name="versionTable" value="a"/>
|
||||
</include>
|
||||
<if test="request.orders != null and request.orders.size() > 0">
|
||||
order by
|
||||
<foreach collection="request.orders" separator="," item="order">
|
||||
<choose>
|
||||
<when test="order.name == 'update_time' or order.name == 'order'">
|
||||
t.${order.name} ${order.type}
|
||||
</when>
|
||||
<when test="order.name == 'create_user'">
|
||||
create_user_id ${order.type}
|
||||
</when>
|
||||
<otherwise>
|
||||
${order.name} ${order.type}
|
||||
</otherwise>
|
||||
</choose>
|
||||
</foreach>
|
||||
</if>
|
||||
|
||||
</select>
|
||||
<select id="selectIds" resultType="java.lang.String">
|
||||
select
|
||||
t.id
|
||||
from
|
||||
test_plan_api_case t
|
||||
inner join
|
||||
api_test_case c
|
||||
on t.api_case_id = c.id
|
||||
<if test="request.planId != null and request.planId!=''">
|
||||
and t.test_plan_id = #{request.planId}
|
||||
</if>
|
||||
inner join
|
||||
api_definition a
|
||||
on
|
||||
c.api_definition_id = a.id
|
||||
<if test="request.protocol != null and request.protocol!=''">
|
||||
and a.protocol = #{request.protocol}
|
||||
</if>
|
||||
<choose>
|
||||
<when test="request.status == 'Trash'">
|
||||
and a.status = 'Trash'
|
||||
</when>
|
||||
<when test="request.status == null">
|
||||
and a.status != 'Trash'
|
||||
</when>
|
||||
<when test="request.status == ''">
|
||||
and a.status != 'Trash'
|
||||
</when>
|
||||
<when test="request.status == 'running'">
|
||||
and t.status IS NULL
|
||||
</when>
|
||||
<otherwise>
|
||||
and t.status = #{request.status}
|
||||
</otherwise>
|
||||
</choose>
|
||||
where 1
|
||||
<if test="request.ids != null and request.ids.size() > 0">
|
||||
<if test="request.projectId != null and request.projectId!=''">
|
||||
and
|
||||
</if>
|
||||
t.id in
|
||||
<foreach collection="request.ids" item="caseId" separator="," open="(" close=")">
|
||||
#{caseId}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="request.name != null and request.name!=''">
|
||||
and (c.name like CONCAT('%', #{request.name},'%') or c.tags like CONCAT('%', #{request.name},'%'))
|
||||
</if>
|
||||
<if test="request.moduleIds != null and request.moduleIds.size() > 0">
|
||||
and a.module_id in
|
||||
<foreach collection="request.moduleIds" item="nodeId" separator="," open="(" close=")">
|
||||
#{nodeId}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="request.filters != null and request.filters.size() > 0">
|
||||
<foreach collection="request.filters.entrySet()" index="key" item="values">
|
||||
<if test="values != null and values.size() > 0">
|
||||
<choose>
|
||||
<when test="key == 'priority'">
|
||||
and c.priority in
|
||||
<foreach collection="values" item="value" separator="," open="(" close=")">
|
||||
#{value}
|
||||
</foreach>
|
||||
</when>
|
||||
<when test="key == 'user_id'">
|
||||
and c.create_user_id in
|
||||
<foreach collection="values" item="value" separator="," open="(" close=")">
|
||||
#{value}
|
||||
</foreach>
|
||||
</when>
|
||||
</choose>
|
||||
inner join
|
||||
api_definition a
|
||||
on
|
||||
c.api_definition_id = a.id
|
||||
where 1
|
||||
<if test="request.protocol != null and request.protocol!=''">
|
||||
and a.protocol = #{request.protocol}
|
||||
</if>
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="request.orders != null and request.orders.size() > 0">
|
||||
order by
|
||||
<foreach collection="request.orders" separator="," item="order">
|
||||
<choose>
|
||||
<when test="order.name == 'update_time' or order.name == 'order'" >
|
||||
t.${order.name} ${order.type}
|
||||
</when>
|
||||
<when test="order.name == 'create_user'">
|
||||
create_user_id ${order.type}
|
||||
</when>
|
||||
<otherwise>
|
||||
c.${order.name} ${order.type}
|
||||
</otherwise>
|
||||
<when test="request.status == 'Trash'">
|
||||
and c.status = 'Trash'
|
||||
</when>
|
||||
<when test="request.status == null">
|
||||
and (c.status IS NULL or c.status != 'Trash')
|
||||
</when>
|
||||
<when test="request.status == ''">
|
||||
and (c.status IS NULL or c.status != 'Trash')
|
||||
</when>
|
||||
<when test="request.status == 'running'">
|
||||
and t.status IS NULL
|
||||
</when>
|
||||
<otherwise>
|
||||
and t.status = #{request.status}
|
||||
</otherwise>
|
||||
</choose>
|
||||
</foreach>
|
||||
</if>
|
||||
</select>
|
||||
<select id="getExecResultByPlanId" resultType="java.lang.String">
|
||||
select status
|
||||
from
|
||||
test_plan_api_case
|
||||
where test_plan_id = #{planId}
|
||||
AND api_case_id in (SELECT id FROM api_test_case WHERE (`status` is null or `status` != 'Trash'))
|
||||
</select>
|
||||
<if test="request.ids != null and request.ids.size() > 0">
|
||||
<if test="request.projectId != null and request.projectId!=''">
|
||||
and a.projectId = #{request.projectId}
|
||||
</if>
|
||||
and t.id in
|
||||
<foreach collection="request.ids" item="caseId" separator="," open="(" close=")">
|
||||
#{caseId}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="request.name != null and request.name!=''">
|
||||
and (c.name like CONCAT('%', #{request.name},'%')
|
||||
or c.tags like CONCAT('%', #{request.name},'%')
|
||||
or c.num like CONCAT('%', #{request.name},'%')
|
||||
)
|
||||
</if>
|
||||
<if test="request.moduleIds != null and request.moduleIds.size() > 0">
|
||||
and a.module_id in
|
||||
<foreach collection="request.moduleIds" item="nodeId" separator="," open="(" close=")">
|
||||
#{nodeId}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="request.filters != null and request.filters.size() > 0">
|
||||
<foreach collection="request.filters.entrySet()" index="key" item="values">
|
||||
<if test="values != null and values.size() > 0">
|
||||
<choose>
|
||||
<when test="key == 'priority'">
|
||||
and c.priority in
|
||||
<foreach collection="values" item="value" separator="," open="(" close=")">
|
||||
#{value}
|
||||
</foreach>
|
||||
</when>
|
||||
<when test="key == 'user_id'">
|
||||
and c.create_user_id in
|
||||
<foreach collection="values" item="value" separator="," open="(" close=")">
|
||||
#{value}
|
||||
</foreach>
|
||||
</when>
|
||||
<when test="key == 'priority'">
|
||||
and a.priority in
|
||||
<foreach collection="values" item="value" separator="," open="(" close=")">
|
||||
#{value}
|
||||
</foreach>
|
||||
</when>
|
||||
<when test="key == 'version_id'">
|
||||
and a.version_id in
|
||||
<foreach collection="values" item="value" separator="," open="(" close=")">
|
||||
#{value}
|
||||
</foreach>
|
||||
</when>
|
||||
</choose>
|
||||
</if>
|
||||
</foreach>
|
||||
</if>
|
||||
<include refid="queryVersionCondition">
|
||||
<property name="versionTable" value="a"/>
|
||||
</include>
|
||||
<if test="request.orders != null and request.orders.size() > 0">
|
||||
order by
|
||||
<foreach collection="request.orders" separator="," item="order">
|
||||
<choose>
|
||||
<when test="order.name == 'update_time' or order.name == 'order'">
|
||||
t.${order.name} ${order.type}
|
||||
</when>
|
||||
<when test="order.name == 'create_user'">
|
||||
create_user_id ${order.type}
|
||||
</when>
|
||||
<otherwise>
|
||||
${order.name} ${order.type}
|
||||
</otherwise>
|
||||
</choose>
|
||||
</foreach>
|
||||
</if>
|
||||
|
||||
<select id="getIdsByPlanId" resultType="java.lang.String">
|
||||
select id
|
||||
from test_plan_api_case
|
||||
where id = #{planId}
|
||||
</select>
|
||||
</select>
|
||||
<select id="selectIds" resultType="java.lang.String">
|
||||
select
|
||||
t.id
|
||||
from
|
||||
test_plan_api_case t
|
||||
inner join
|
||||
api_test_case c
|
||||
on t.api_case_id = c.id
|
||||
<if test="request.planId != null and request.planId!=''">
|
||||
and t.test_plan_id = #{request.planId}
|
||||
</if>
|
||||
inner join
|
||||
api_definition a
|
||||
on
|
||||
c.api_definition_id = a.id
|
||||
<if test="request.protocol != null and request.protocol!=''">
|
||||
and a.protocol = #{request.protocol}
|
||||
</if>
|
||||
<choose>
|
||||
<when test="request.status == 'Trash'">
|
||||
and a.status = 'Trash'
|
||||
</when>
|
||||
<when test="request.status == null">
|
||||
and a.status != 'Trash'
|
||||
</when>
|
||||
<when test="request.status == ''">
|
||||
and a.status != 'Trash'
|
||||
</when>
|
||||
<when test="request.status == 'running'">
|
||||
and t.status IS NULL
|
||||
</when>
|
||||
<otherwise>
|
||||
and t.status = #{request.status}
|
||||
</otherwise>
|
||||
</choose>
|
||||
where 1
|
||||
<if test="request.ids != null and request.ids.size() > 0">
|
||||
<if test="request.projectId != null and request.projectId!=''">
|
||||
and
|
||||
</if>
|
||||
t.id in
|
||||
<foreach collection="request.ids" item="caseId" separator="," open="(" close=")">
|
||||
#{caseId}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="request.name != null and request.name!=''">
|
||||
and (c.name like CONCAT('%', #{request.name},'%') or c.tags like CONCAT('%', #{request.name},'%'))
|
||||
</if>
|
||||
<if test="request.moduleIds != null and request.moduleIds.size() > 0">
|
||||
and a.module_id in
|
||||
<foreach collection="request.moduleIds" item="nodeId" separator="," open="(" close=")">
|
||||
#{nodeId}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="request.filters != null and request.filters.size() > 0">
|
||||
<foreach collection="request.filters.entrySet()" index="key" item="values">
|
||||
<if test="values != null and values.size() > 0">
|
||||
<choose>
|
||||
<when test="key == 'priority'">
|
||||
and c.priority in
|
||||
<foreach collection="values" item="value" separator="," open="(" close=")">
|
||||
#{value}
|
||||
</foreach>
|
||||
</when>
|
||||
<when test="key == 'user_id'">
|
||||
and c.create_user_id in
|
||||
<foreach collection="values" item="value" separator="," open="(" close=")">
|
||||
#{value}
|
||||
</foreach>
|
||||
</when>
|
||||
</choose>
|
||||
</if>
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="request.orders != null and request.orders.size() > 0">
|
||||
order by
|
||||
<foreach collection="request.orders" separator="," item="order">
|
||||
<choose>
|
||||
<when test="order.name == 'update_time' or order.name == 'order'">
|
||||
t.${order.name} ${order.type}
|
||||
</when>
|
||||
<when test="order.name == 'create_user'">
|
||||
create_user_id ${order.type}
|
||||
</when>
|
||||
<otherwise>
|
||||
c.${order.name} ${order.type}
|
||||
</otherwise>
|
||||
</choose>
|
||||
</foreach>
|
||||
</if>
|
||||
</select>
|
||||
<select id="getExecResultByPlanId" resultType="java.lang.String">
|
||||
select status
|
||||
from test_plan_api_case
|
||||
where test_plan_id = #{planId}
|
||||
AND api_case_id in (SELECT id FROM api_test_case WHERE (`status` is null or `status` != 'Trash'))
|
||||
</select>
|
||||
|
||||
<select id="getNotRelevanceCaseIds" resultType="java.lang.String">
|
||||
select t.id
|
||||
from test_plan_api_case t
|
||||
inner join api_test_case c
|
||||
on c.id = t.api_case_id
|
||||
<if test="relevanceProjectIds != null and relevanceProjectIds.size() > 0">
|
||||
and c.project_id not in
|
||||
<foreach collection="relevanceProjectIds" item="projectId" separator="," open="(" close=")">
|
||||
#{projectId}
|
||||
</foreach>
|
||||
</if>
|
||||
where t.test_plan_id = #{planId}
|
||||
</select>
|
||||
<select id="getStatusByTestPlanId" resultType="java.lang.String">
|
||||
SELECT `status` FROM test_plan_api_case WHERE test_plan_id = #{0}
|
||||
</select>
|
||||
<select id="getIdsByPlanId" resultType="java.lang.String">
|
||||
select id
|
||||
from test_plan_api_case
|
||||
where id = #{planId}
|
||||
</select>
|
||||
|
||||
<select id="getNotRelevanceCaseIds" resultType="java.lang.String">
|
||||
select t.id
|
||||
from test_plan_api_case t
|
||||
inner join api_test_case c
|
||||
on c.id = t.api_case_id
|
||||
<if test="relevanceProjectIds != null and relevanceProjectIds.size() > 0">
|
||||
and c.project_id not in
|
||||
<foreach collection="relevanceProjectIds" item="projectId" separator="," open="(" close=")">
|
||||
#{projectId}
|
||||
</foreach>
|
||||
</if>
|
||||
where t.test_plan_id = #{planId}
|
||||
</select>
|
||||
<select id="getStatusByTestPlanId" resultType="java.lang.String">
|
||||
SELECT `status`
|
||||
FROM test_plan_api_case
|
||||
WHERE test_plan_id = #{0}
|
||||
</select>
|
||||
<select id="selectForPlanReport" resultType="io.metersphere.track.dto.PlanReportCaseDTO">
|
||||
select id,status from test_plan_api_case where test_plan_id = #{planId} and api_case_id IN (
|
||||
SELECT id FROM api_test_case where status is null or status != 'Trash'
|
||||
)
|
||||
select id, status
|
||||
from test_plan_api_case
|
||||
where test_plan_id = #{planId}
|
||||
and api_case_id IN (
|
||||
SELECT id
|
||||
FROM api_test_case
|
||||
where status is null
|
||||
or status
|
||||
!= 'Trash'
|
||||
)
|
||||
</select>
|
||||
<select id="getFailureList" resultType="io.metersphere.api.dto.automation.TestPlanFailureApiDTO">
|
||||
select
|
||||
select
|
||||
t.id,
|
||||
c.id as case_id, c.project_id, c.name, c.api_definition_id, c.priority, c.create_user_id,
|
||||
c.num,c.create_user_id AS create_user,
|
||||
t.status execResult
|
||||
from
|
||||
from
|
||||
test_plan_api_case t
|
||||
inner join
|
||||
inner join
|
||||
api_test_case c
|
||||
on t.api_case_id = c.id
|
||||
and t.test_plan_id = #{planId}
|
||||
and t.test_plan_id = #{planId}
|
||||
<if test="status == 'unExecute'">
|
||||
and (t.status in ('Stop','unExecute') or t.status IS NULL)
|
||||
</if>
|
||||
<if test="status != null and status != 'unExecute'">
|
||||
and t.status = #{status}
|
||||
</if>
|
||||
and (c.status != 'Trash' or c.status is null)
|
||||
where t.test_plan_id = #{planId} ORDER BY t.order DESC
|
||||
<if test="status != null and status != 'unExecute'">
|
||||
and t.status = #{status}
|
||||
</if>
|
||||
and (c.status != 'Trash' or c.status is null)
|
||||
where t.test_plan_id = #{planId} ORDER BY t.order DESC
|
||||
</select>
|
||||
|
||||
<select id="getFailureListByIds" resultType="io.metersphere.api.dto.automation.TestPlanFailureApiDTO">
|
||||
select
|
||||
t.id,
|
||||
c.id as case_id, c.project_id, c.name, c.api_definition_id, c.priority, c.create_user_id,
|
||||
c.num,t.create_user,
|
||||
t.status execResult
|
||||
from
|
||||
test_plan_api_case t
|
||||
inner join
|
||||
api_test_case c
|
||||
on t.api_case_id = c.id
|
||||
<if test="status != null">
|
||||
and t.status = 'error'
|
||||
</if>
|
||||
where t.id IN
|
||||
<foreach collection="ids" item="id" separator="," open="(" close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
ORDER BY t.order DESC
|
||||
</select>
|
||||
<select id="getFailureListByIds" resultType="io.metersphere.api.dto.automation.TestPlanFailureApiDTO">
|
||||
select
|
||||
t.id,
|
||||
c.id as case_id, c.project_id, c.name, c.api_definition_id, c.priority, c.create_user_id,
|
||||
c.num,t.create_user,
|
||||
t.status execResult
|
||||
from
|
||||
test_plan_api_case t
|
||||
inner join
|
||||
api_test_case c
|
||||
on t.api_case_id = c.id
|
||||
<if test="status != null">
|
||||
and t.status = 'error'
|
||||
</if>
|
||||
where t.id IN
|
||||
<foreach collection="ids" item="id" separator="," open="(" close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
ORDER BY t.order DESC
|
||||
</select>
|
||||
|
||||
|
||||
<select id="selectPlanIds" resultType="java.lang.String">
|
||||
select DISTINCT test_plan_id from test_plan_api_case;
|
||||
</select>
|
||||
<select id="getIdsOrderByUpdateTime" resultType="java.lang.String">
|
||||
select id from test_plan_api_case where test_plan_id = #{planId} order by update_time ASC;
|
||||
</select>
|
||||
<select id="selectPlanIds" resultType="java.lang.String">
|
||||
select DISTINCT test_plan_id
|
||||
from test_plan_api_case;
|
||||
</select>
|
||||
<select id="getIdsOrderByUpdateTime" resultType="java.lang.String">
|
||||
select id
|
||||
from test_plan_api_case
|
||||
where test_plan_id = #{planId}
|
||||
order by update_time ASC;
|
||||
</select>
|
||||
|
||||
<select id="getLastOrder" resultType="java.lang.Long">
|
||||
select `order` from test_plan_api_case where test_plan_id = #{planId}
|
||||
<if test="baseOrder != null">
|
||||
and `order` > #{baseOrder}
|
||||
</if>
|
||||
order by `order` desc limit 1;
|
||||
</select>
|
||||
<select id="getLastOrder" resultType="java.lang.Long">
|
||||
select `order` from test_plan_api_case where test_plan_id = #{planId}
|
||||
<if test="baseOrder != null">
|
||||
and `order` > #{baseOrder}
|
||||
</if>
|
||||
order by `order` desc limit 1;
|
||||
</select>
|
||||
|
||||
<select id="getPreOrder" resultType="java.lang.Long">
|
||||
select `order` from test_plan_api_case where test_plan_id = #{planId}
|
||||
<if test="baseOrder != null">
|
||||
and `order` < #{baseOrder}
|
||||
</if>
|
||||
order by `order` desc limit 1;
|
||||
</select>
|
||||
<select id="getPreOrder" resultType="java.lang.Long">
|
||||
select `order` from test_plan_api_case where test_plan_id = #{planId}
|
||||
<if test="baseOrder != null">
|
||||
and `order` < #{baseOrder}
|
||||
</if>
|
||||
order by `order` desc limit 1;
|
||||
</select>
|
||||
<select id="selectByIdsAndStatusIsNotTrash" resultType="io.metersphere.base.domain.TestPlanApiCase">
|
||||
SELECT
|
||||
plan.*
|
||||
FROM
|
||||
test_plan_api_case plan
|
||||
INNER JOIN api_test_case api ON plan.api_case_id = api.id
|
||||
WHERE
|
||||
(api.`status` is null OR api.`status` != 'Trash') AND plan.test_plan_id IN
|
||||
<foreach collection="ids" item="v" separator="," open="(" close=")">
|
||||
#{v}
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
<sql id="queryVersionCondition">
|
||||
<if test="request.versionId != null">
|
||||
and ${versionTable}.version_id = #{request.versionId}
|
||||
</if>
|
||||
<if test="request.refId != null">
|
||||
and ${versionTable}.ref_id = #{request.refId}
|
||||
</if>
|
||||
</sql>
|
||||
<sql id="queryVersionCondition">
|
||||
<if test="request.versionId != null">
|
||||
and ${versionTable}.version_id = #{request.versionId}
|
||||
</if>
|
||||
<if test="request.refId != null">
|
||||
and ${versionTable}.ref_id = #{request.refId}
|
||||
</if>
|
||||
</sql>
|
||||
</mapper>
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
package io.metersphere.base.mapper.ext;
|
||||
|
||||
import io.metersphere.base.domain.TestPlanApiScenario;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface ExtTestPlanApiScenarioMapper {
|
||||
List<TestPlanApiScenario> selectByIdsAndStatusIsNotTrash(@Param("ids") List<String> ids);
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="io.metersphere.base.mapper.ext.ExtTestPlanApiScenarioMapper">
|
||||
<select id="selectByIdsAndStatusIsNotTrash" resultType="io.metersphere.base.domain.TestPlanApiScenario">
|
||||
SELECT
|
||||
plan.*
|
||||
FROM
|
||||
test_plan_api_scenario plan
|
||||
INNER JOIN api_scenario api ON plan.api_scenario_id = api.id
|
||||
WHERE
|
||||
(api.`status` is null OR api.`status` != 'Trash') AND plan.test_plan_id IN
|
||||
<foreach collection="ids" item="v" separator="," open="(" close=")">
|
||||
#{v}
|
||||
</foreach>
|
||||
</select>
|
||||
</mapper>
|
|
@ -35,9 +35,9 @@ import io.metersphere.performance.service.MetricQueryService;
|
|||
import io.metersphere.performance.service.PerformanceReportService;
|
||||
import io.metersphere.performance.service.PerformanceTestService;
|
||||
import io.metersphere.service.*;
|
||||
import io.metersphere.track.factory.ReportComponentFactory;
|
||||
import io.metersphere.track.domain.ReportComponent;
|
||||
import io.metersphere.track.dto.*;
|
||||
import io.metersphere.track.factory.ReportComponentFactory;
|
||||
import io.metersphere.track.request.testcase.PlanCaseRelevanceRequest;
|
||||
import io.metersphere.track.request.testcase.QueryTestPlanRequest;
|
||||
import io.metersphere.track.request.testplan.AddTestPlanRequest;
|
||||
|
@ -184,6 +184,8 @@ public class TestPlanService {
|
|||
private ApiDefinitionExecResultMapper apiDefinitionExecResultMapper;
|
||||
@Resource
|
||||
private ExtApiDefinitionExecResultMapper extApiDefinitionExecResultMapper;
|
||||
@Resource
|
||||
private ExtTestPlanApiScenarioMapper extTestPlanApiScenarioMapper;
|
||||
|
||||
public synchronized TestPlan addTestPlan(AddTestPlanRequest testPlan) {
|
||||
if (getTestPlanByName(testPlan.getName()).size() > 0) {
|
||||
|
@ -1924,6 +1926,10 @@ public class TestPlanService {
|
|||
}
|
||||
|
||||
public String runPlan(TestplanRunRequest testplanRunRequest) {
|
||||
//检查是否有可以执行的用例
|
||||
if (!haveExecCase(testplanRunRequest.getTestPlanId())) {
|
||||
MSException.throwException(Translator.get("plan_warning"));
|
||||
}
|
||||
String envType = testplanRunRequest.getEnvironmentType();
|
||||
Map<String, String> envMap = testplanRunRequest.getEnvMap();
|
||||
String environmentGroupId = testplanRunRequest.getEnvironmentGroupId();
|
||||
|
@ -1999,16 +2005,14 @@ public class TestPlanService {
|
|||
if (StringUtils.isBlank(id)) {
|
||||
return false;
|
||||
}
|
||||
TestPlanApiCaseExample apiCaseExample = new TestPlanApiCaseExample();
|
||||
apiCaseExample.createCriteria().andTestPlanIdEqualTo(id);
|
||||
List<TestPlanApiCase> testPlanApiCases = testPlanApiCaseMapper.selectByExample(apiCaseExample);
|
||||
List<String> ids = new ArrayList<>();
|
||||
ids.add(id);
|
||||
List<TestPlanApiCase> testPlanApiCases = extTestPlanApiCaseMapper.selectByIdsAndStatusIsNotTrash(ids);
|
||||
if (!CollectionUtils.isEmpty(testPlanApiCases)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
TestPlanApiScenarioExample apiScenarioExample = new TestPlanApiScenarioExample();
|
||||
apiScenarioExample.createCriteria().andTestPlanIdEqualTo(id);
|
||||
List<TestPlanApiScenario> testPlanApiScenarios = testPlanApiScenarioMapper.selectByExample(apiScenarioExample);
|
||||
List<TestPlanApiScenario> testPlanApiScenarios = extTestPlanApiScenarioMapper.selectByIdsAndStatusIsNotTrash(ids);
|
||||
if (!CollectionUtils.isEmpty(testPlanApiScenarios)) {
|
||||
return true;
|
||||
}
|
||||
|
@ -2153,6 +2157,7 @@ public class TestPlanService {
|
|||
Map<String, String> executeQueue = new LinkedHashMap<>();
|
||||
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
StringBuilder haveExecCaseBuilder = new StringBuilder();
|
||||
for (int i = 0; i < planList.size(); i++) {
|
||||
if (StringUtils.isBlank(planList.get(i).getRunModeConfig())) {
|
||||
StringBuilder append = stringBuilder.append("请保存[").append(planList.get(i).getName()).append("]的运行配置");
|
||||
|
@ -2160,8 +2165,14 @@ public class TestPlanService {
|
|||
append.append("/");
|
||||
}
|
||||
}
|
||||
if (!haveExecCase(planList.get(i).getId())) {
|
||||
haveExecCaseBuilder.append(planList.get(i).getName()).append("; ");
|
||||
}
|
||||
}
|
||||
|
||||
if (StringUtils.isNotEmpty(haveExecCaseBuilder)) {
|
||||
MSException.throwException(Translator.get("track_test_plan") + ": " + haveExecCaseBuilder.toString() + " :" + Translator.get("plan_warning"));
|
||||
}
|
||||
if (StringUtils.isNotEmpty(stringBuilder)) {
|
||||
MSException.throwException(stringBuilder.toString());
|
||||
}
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 7f405105bf50af4ae2f1a240059c742f3ac7c729
|
||||
Subproject commit 830bad0961b3ec2eaff21e9eac382d16f0521639
|
|
@ -217,8 +217,8 @@ import_xmind_not_found=Test case not found
|
|||
license_valid_license_error=Authorization authentication failed
|
||||
test_review_task_notice=Test review task notice
|
||||
swagger_url_scheduled_import_notification=SwaggerUrl Scheduled import notification
|
||||
Swagger_parse_error =Swagger parsing failed, please confirm file format is correct!
|
||||
Swagger_parse_error_with_auth =Swagger parsing failed. Please check whether authentication information is correct or file format is correct!
|
||||
Swagger_parse_error=Swagger parsing failed, please confirm file format is correct!
|
||||
Swagger_parse_error_with_auth=Swagger parsing failed. Please check whether authentication information is correct or file format is correct!
|
||||
test_track.length_less_than=The title is too long, the length must be less than
|
||||
# check owner
|
||||
check_owner_project=The current user does not have permission to operate this project
|
||||
|
@ -388,3 +388,4 @@ cmdExtractElement=element extraction
|
|||
tcp_mock_not_unique=This tcp port is be used
|
||||
no_tcp_mock_port=No idle tcp port, please contact administrators.
|
||||
name_already_exists_in_module=Name already exists in same module
|
||||
plan_warning=There is no associated executable use case under the test plan
|
|
@ -387,3 +387,4 @@ cmdExtractElement=提取元素信息
|
|||
tcp_mock_not_unique=该TCP端口号已被使用
|
||||
no_tcp_mock_port=无可用的TCP端口号,请联系管理员
|
||||
name_already_exists_in_module=同层级下已经存在
|
||||
plan_warning=测试计划下没有关联可以执行的用例
|
||||
|
|
|
@ -386,3 +386,4 @@ cmdExtractElement=提取元素信息
|
|||
tcp_mock_not_unique=該TCP端口號已被使用
|
||||
no_tcp_mock_port=無可用的TCP端口號,請聯繫管理員
|
||||
name_already_exists_in_module=同層級下已存在
|
||||
plan_warning=測試計劃下沒有關聯可以執行的用例
|
|
@ -1 +1 @@
|
|||
Subproject commit 20b5563776f552ecd1b84bed3bcf50e5cbcaa9b0
|
||||
Subproject commit 12370ba86adfdf31b11a30d48a59c3715490b351
|
Loading…
Reference in New Issue