Browse Source

feat: 黑盒测试步骤增加 预期结果 和 状态两个字段,增加对应的更新方法

370774330@qq.com 5 năm trước cách đây
mục cha
commit
8cfa7fcca1

+ 17 - 3
web/src/main/java/cn/seecoder/web/controller/func_test/FuncTestController.java

@@ -1,5 +1,6 @@
 package cn.seecoder.web.controller.func_test;
 
+import cn.seecoder.web.model.enums.FuncTestStepState;
 import cn.seecoder.web.model.vo.func_test.FuncTestRecordVO;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiImplicitParam;
@@ -109,11 +110,12 @@ public class FuncTestController {
     @ApiOperation(value = "更新测试用例步骤内容", httpMethod = "PUT")
     @ApiImplicitParams({
             @ApiImplicitParam(name = "testStepId",dataType ="int", paramType = "query"),
-            @ApiImplicitParam(name = "description",dataType ="string", paramType = "query")
+            @ApiImplicitParam(name = "description",dataType ="string", paramType = "query"),
+            @ApiImplicitParam(name = "expectation",dataType ="string", paramType = "query")
     })
     @PutMapping("/steps")
-    public Response updateTestStepDescription(@RequestParam("testStepId") Integer testStepId, @RequestParam("description") String description){
-        funcTestService.updateTestStepDescription(testStepId, description);
+    public Response updateTestStepInfo(@RequestParam("testStepId") Integer testStepId, @RequestParam("description") String description, @RequestParam("expectation") String expectation){
+        funcTestService.updateTestStepInfo(testStepId, description, expectation);
         return Response.buildSuccess();
     }
 
@@ -125,6 +127,18 @@ public class FuncTestController {
         return Response.buildSuccess();
     }
 
+    @ApiOperation(value = "删除测试用例步骤", httpMethod = "DELETE")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "testStepId",dataType ="int", paramType = "query"),
+            @ApiImplicitParam(name = "state",dataType ="string", paramType = "query")
+    })
+    @PutMapping("/steps/state")
+    public Response updateTestStepState(@RequestParam("testStepId") Integer testStepId,
+                                        @RequestParam("state")FuncTestStepState state){
+        funcTestService.updateTestStepState(testStepId, state);
+        return Response.buildSuccess();
+    }
+
     @ApiOperation(value = "获取当前部署的所有相关测试用例历史记录信息", httpMethod = "GET")
     @ApiImplicitParam(name = "projectId",dataType ="int", paramType = "query")
     @GetMapping("/record/latest")

+ 1 - 1
web/src/main/java/cn/seecoder/web/dao/func_test/FuncTestStepMapper.java

@@ -26,5 +26,5 @@ public interface FuncTestStepMapper {
     int delete(Integer id);
 
     @Select("select * from func_test_step where test_case_id = #{testCaseId}")
-    List<FuncTestStepPO> selectByProjectId(Integer testCaseId);
+    List<FuncTestStepPO> selectByTestCaseId(Integer testCaseId);
 }

+ 31 - 0
web/src/main/java/cn/seecoder/web/model/enums/FuncTestStepState.java

@@ -0,0 +1,31 @@
+package cn.seecoder.web.model.enums;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+/**
+ * @author PuHong Weng
+ * @date 2021/5/2
+ * @description:
+ */
+public enum  FuncTestStepState {
+
+    @JsonProperty("待测试")
+    WAITING("待测试"),
+
+    @JsonProperty("已测试")
+    PASS("已测试"),
+
+    @JsonProperty("出现BUG")
+    BUG("出现BUG");
+
+    private final String value;
+
+    FuncTestStepState(String value){
+        this.value=value;
+    }
+
+    @Override
+    public String toString(){
+        return value;
+    }
+}

+ 11 - 0
web/src/main/java/cn/seecoder/web/model/po/func_test/FuncTestStepPO.java

@@ -1,5 +1,6 @@
 package cn.seecoder.web.model.po.func_test;
 
+import cn.seecoder.web.model.enums.FuncTestStepState;
 import lombok.AllArgsConstructor;
 import lombok.Builder;
 import lombok.Data;
@@ -20,5 +21,15 @@ public class FuncTestStepPO {
 
     Integer testCaseId;
 
+    /**
+     * 步骤描述
+     */
     String description;
+
+    /**
+     * 步骤执行后预期结果描述描述
+     */
+    String expectation;
+
+    FuncTestStepState state;
 }

+ 14 - 0
web/src/main/java/cn/seecoder/web/model/vo/func_test/FuncTestStepVO.java

@@ -1,10 +1,13 @@
 package cn.seecoder.web.model.vo.func_test;
 
+import cn.seecoder.web.model.enums.FuncTestStepState;
+import cn.seecoder.web.model.po.func_test.FuncTestStepPO;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.AllArgsConstructor;
 import lombok.Builder;
 import lombok.Data;
 import lombok.NoArgsConstructor;
+import org.springframework.beans.BeanUtils;
 
 /**
  * @author PuHong Weng
@@ -25,4 +28,15 @@ public class FuncTestStepVO {
 
     @ApiModelProperty("步骤描述")
     String description;
+
+    @ApiModelProperty("步骤执行后预期结果描述描述")
+    String expectation;
+
+    @ApiModelProperty("步骤状态")
+    FuncTestStepState state;
+
+    public FuncTestStepVO(FuncTestStepPO po){
+        BeanUtils.copyProperties(po,this);
+    }
+
 }

+ 6 - 1
web/src/main/java/cn/seecoder/web/service/func_test/FuncTestService.java

@@ -1,5 +1,6 @@
 package cn.seecoder.web.service.func_test;
 
+import cn.seecoder.web.model.enums.FuncTestStepState;
 import cn.seecoder.web.model.vo.func_test.FuncTestCaseVO;
 import cn.seecoder.web.model.vo.func_test.FuncTestRecordVO;
 import cn.seecoder.web.model.vo.func_test.FuncTestStepVO;
@@ -29,9 +30,13 @@ public interface FuncTestService {
 
     void createEmptyTestStep(Integer testCaseId);
 
-    void updateTestStepDescription(Integer testStepId, String description);
+    void updateTestStepInfo(Integer testStepId, String description, String expectation);
 
     void deleteTestStep(Integer testStepId);
 
+    void updateTestStepState(Integer testStepId, FuncTestStepState state);
+
     List<FuncTestRecordVO> getLatestRecord(Integer projectId);
+
+
 }

+ 11 - 4
web/src/main/java/cn/seecoder/web/service/impl/func_test/FuncFuncTestServiceImpl.java

@@ -6,6 +6,7 @@ import cn.seecoder.web.dao.func_test.FuncTestCaseMapper;
 import cn.seecoder.web.dao.func_test.FuncTestRecordMapper;
 import cn.seecoder.web.dao.func_test.FuncTestStepMapper;
 import cn.seecoder.web.model.enums.FuncTestOperatorEnum;
+import cn.seecoder.web.model.enums.FuncTestStepState;
 import cn.seecoder.web.model.po.pipeline.PipelinePO;
 import cn.seecoder.web.model.po.pipeline.PipelineRecordPO;
 import cn.seecoder.web.model.po.func_test.FuncTestCasePO;
@@ -59,7 +60,8 @@ public class FuncFuncTestServiceImpl implements FuncTestService {
 
     @Override
     public List<FuncTestStepVO> getTestSteps(Integer testCaseId) {
-        return null;
+        return funcTestStepMapper.selectByTestCaseId(testCaseId).stream()
+                .map(FuncTestStepVO::new).collect(Collectors.toList());
     }
 
     @Override
@@ -127,13 +129,18 @@ public class FuncFuncTestServiceImpl implements FuncTestService {
     @Override
     @Transactional
     public void createEmptyTestStep(Integer testCaseId) {
-        funcTestStepMapper.insert(FuncTestStepPO.builder().description("").testCaseId(testCaseId).build());
+        funcTestStepMapper.insert(FuncTestStepPO.builder().description("").expectation("").state(FuncTestStepState.WAITING).testCaseId(testCaseId).build());
     }
 
     @Override
     @Transactional
-    public void updateTestStepDescription(Integer testStepId, String description) {
-        funcTestStepMapper.insert(FuncTestStepPO.builder().description(description).id(testStepId).build());
+    public void updateTestStepInfo(Integer testStepId, String description, String expectation) {
+        funcTestStepMapper.update(FuncTestStepPO.builder().description(description).expectation(expectation).id(testStepId).build());
+    }
+
+    @Override
+    public void updateTestStepState(Integer testStepId, FuncTestStepState state) {
+        funcTestStepMapper.update(FuncTestStepPO.builder().state(state).id(testStepId).build());
     }
 
     @Override

+ 4 - 2
web/src/main/resources/sql/table_init.sql

@@ -20,8 +20,10 @@ create table if not exists devcloud.func_test_step
 (
     id           int auto_increment
         primary key,
-    test_case_id int  null,
-    description  text null,
+    test_case_id int         null,
+    description  text        null,
+    expectation  text        null,
+    statev       varchar(11) null,
     constraint test_step_test_case_id_fk
         foreign key (test_case_id) references devcloud.func_test_case (id)
             on delete set null