Commit ae297232 authored by 王飞's avatar 王飞

1、新建“测试用例”&“用例矩阵”相关代码

parent 443fcf00
package com.ruoyi.domain;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* 测试用例
* @TableName t_test_usecase
*/
@TableName(value ="t_test_usecase")
@Data
public class TestUseCase implements Serializable {
/**
* 主键
*/
@ApiModelProperty("主键")
@TableId(type = IdType.ASSIGN_ID)
@JsonFormat(shape = JsonFormat.Shape.STRING)
private Long id;
/**
* 测试场景id
*/
@ApiModelProperty("测试场景id")
@JsonFormat(shape = JsonFormat.Shape.STRING)
private Long testScenarioId;
/**
* 测试类型id
*/
@ApiModelProperty("测试类型id")
@JsonFormat(shape = JsonFormat.Shape.STRING)
private Long testTypeId;
/**
* 用例编号
*/
@ApiModelProperty("用例编号")
private String usecaseNo;
/**
* 用例名称
*/
@ApiModelProperty("用例名称")
private String name;
/**
* 工具
*/
@ApiModelProperty("工具")
private String tools;
/**
* 对应输入
*/
@ApiModelProperty("对应输入")
private String input;
/**
* 用例描述
*/
@ApiModelProperty("用例描述")
private String description;
/**
* 返回用例在矩阵中的坐标
* @return
*/
public String getCoordinates() {
return String.valueOf(testScenarioId) + String.valueOf(testTypeId);
}
}
\ No newline at end of file
package com.ruoyi.domain.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@ApiModel(value = "MatrixColumnVO", description = "用例矩阵-列")
@Data
public class MatrixColumnVO {
@ApiModelProperty("列名称")
private String title;
@ApiModelProperty("用例id;没有用例则为null")
private Long useCaseId;
}
package com.ruoyi.domain.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
@ApiModel(value = "MatrixRowVO", description = "用例矩阵-行")
@Data
public class MatrixRowVO {
@ApiModelProperty("行名称")
private String name;
@ApiModelProperty("当前行包含的所有列")
private List<MatrixColumnVO> columns;
}
package com.ruoyi.mapper;
import com.ruoyi.domain.TestUseCase;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* @author wangfei
* @description 针对表【t_test_usecase(测试用例)】的数据库操作Mapper
* @createDate 2024-02-18 13:41:28
* @Entity com.ruoyi.domain.TestUseCase
*/
public interface TestUseCaseMapper extends BaseMapper<TestUseCase> {
}
package com.ruoyi.service;
import com.ruoyi.web.response.MatrixResponse;
public interface MatrixService {
MatrixResponse getMatrix();
}
package com.ruoyi.service;
import com.ruoyi.domain.TestUseCase;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* @author wangfei
* @description 针对表【t_test_usecase(测试用例)】的数据库操作Service
* @createDate 2024-02-18 13:41:28
*/
public interface TestUseCaseService extends IService<TestUseCase> {
}
package com.ruoyi.service.impl;
import com.ruoyi.domain.TestUseCase;
import com.ruoyi.service.MatrixService;
import com.ruoyi.service.TestUseCaseService;
import com.ruoyi.web.response.MatrixResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class MatrixServiceImpl implements MatrixService {
@Autowired
private TestUseCaseService testUseCaseService;
@Override
public MatrixResponse getMatrix() {
List<TestUseCase> useCases = testUseCaseService.list();
return null;
}
}
package com.ruoyi.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.domain.TestUseCase;
import com.ruoyi.service.TestUseCaseService;
import com.ruoyi.mapper.TestUseCaseMapper;
import org.springframework.stereotype.Service;
/**
* @author wangfei
* @description 针对表【t_test_usecase(测试用例)】的数据库操作Service实现
* @createDate 2024-02-18 13:41:28
*/
@Service
public class TestUseCaseServiceImpl extends ServiceImpl<TestUseCaseMapper, TestUseCase>
implements TestUseCaseService{
}
package com.ruoyi.web.response;
import com.ruoyi.domain.vo.MatrixColumnVO;
import com.ruoyi.domain.vo.MatrixRowVO;
import io.swagger.annotations.ApiModel;
import lombok.Data;
import java.util.List;
@ApiModel(value = "MatrixResponse", description = "用例矩阵")
@Data
public class MatrixResponse {
private List<MatrixColumnVO> header;
private List<MatrixRowVO> rows;
}
<?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="com.ruoyi.mapper.TestUseCaseMapper">
<resultMap id="BaseResultMap" type="com.ruoyi.domain.TestUseCase">
<id property="id" column="id" jdbcType="BIGINT"/>
<result property="testScenarioId" column="test_scenario_id" jdbcType="BIGINT"/>
<result property="testTypeId" column="test_type_id" jdbcType="BIGINT"/>
<result property="usecaseNo" column="usecase_no" jdbcType="VARCHAR"/>
<result property="name" column="name" jdbcType="VARCHAR"/>
<result property="tools" column="tools" jdbcType="VARCHAR"/>
<result property="input" column="input" jdbcType="VARCHAR"/>
<result property="description" column="description" jdbcType="VARCHAR"/>
</resultMap>
<sql id="Base_Column_List">
id,test_scenario_id,test_type_id,
usecase_no,name,tools,
input,description
</sql>
</mapper>
package com.ruoyi;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import java.util.ArrayList;
@SpringBootTest
public class MatrixTest {
@Test
public void generateMatrixTest() {
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment