提交 c30917f8 authored 作者: 黄承天's avatar 黄承天

完成测试系统这一块相关功能接口

增加测试系统的新增和查询接口 增加根据测试系统id查询测试用例的接口 增加根据测试系统id批量执行其所有测试用例的接口
上级 f70f2272
package com.zjty.automatedtesting.controller;
import com.zjty.automatedtesting.pojo.test.System;
import com.zjty.automatedtesting.service.SystemService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
@SuppressWarnings("SpringJavaAutowiredFieldsWarningInspection")
@RequestMapping("/system")
@RestController
@Api(tags = "测试系统")
@CrossOrigin
public class SystemController {
@Autowired
SystemService systemService;
@ApiOperation(value = "新增测试系统.")
@PostMapping(value="/create")
public ResponseEntity<System> create(@RequestBody System system){
system = systemService.create(system);
return ResponseEntity.ok(system);
}
@ApiOperation(value = "根据id获取测试系统.")
@GetMapping(value="/get/{id}")
public ResponseEntity<System> findById(@PathVariable String id){
System system = systemService.findById(id);
return ResponseEntity.ok(system);
}
}
...@@ -13,6 +13,7 @@ import org.springframework.web.bind.annotation.*; ...@@ -13,6 +13,7 @@ import org.springframework.web.bind.annotation.*;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors;
/** /**
* @author C * @author C
...@@ -31,38 +32,52 @@ public class TestCaseController { ...@@ -31,38 +32,52 @@ public class TestCaseController {
CaseService caseService; CaseService caseService;
@ApiOperation(value = "提供测试用例数据.执行测试并返回测试结果报告.") @ApiOperation(value = "提供测试用例数据.执行测试并返回测试结果报告.")
@PostMapping(value="/execute") @PostMapping(value = "/execute")
public ResponseEntity<ReportVo> execute(@RequestBody CaseVo caseVo){ public ResponseEntity<ReportVo> execute(@RequestBody CaseVo caseVo) {
ReportVo execute = seleniumService.execute(caseVo); ReportVo execute = seleniumService.execute(caseVo);
return ResponseEntity.ok(execute); return ResponseEntity.ok(execute);
} }
@ApiOperation(value = "保存测试用例.",notes = "不附带id为新增 附带id为修改") @ApiOperation(value = "根据测试系统id.执行改测试系统下的所有测试用例并返回测试结果报告的集合.")
@PostMapping(value="/save") @GetMapping(value = "/execute/system/{systemId}")
public ResponseEntity<Map<String,String>> save(@RequestBody CaseVo caseVo){ public ResponseEntity<List<ReportVo>> execute(@PathVariable String systemId) {
List<CaseVo> caseVoList = caseService.findBySystemId(systemId);
return ResponseEntity.ok(caseVoList.stream()
.map(caseVo -> seleniumService.execute(caseVo))
.collect(Collectors.toList()));
}
@ApiOperation(value = "保存测试用例.", notes = "不附带id为新增 附带id为修改")
@PostMapping(value = "/save")
public ResponseEntity<Map<String, String>> save(@RequestBody CaseVo caseVo) {
caseService.save(caseVo); caseService.save(caseVo);
return ResponseEntity.ok(ImmutableMap.of("message","success")); return ResponseEntity.ok(ImmutableMap.of("message", "success"));
} }
@ApiOperation(value = "删除测试用例.") @ApiOperation(value = "删除测试用例.")
@DeleteMapping(value="/delete/{id}") @DeleteMapping(value = "/delete/{id}")
public ResponseEntity<Map<String,String>> findTestText(@PathVariable Integer id){ public ResponseEntity<Map<String, String>> findTestText(@PathVariable Integer id) {
caseService.delete(id); caseService.delete(id);
return ResponseEntity.ok(ImmutableMap.of("message","success")); return ResponseEntity.ok(ImmutableMap.of("message", "success"));
} }
@ApiOperation(value = "获取全部测试用例.") @ApiOperation(value = "获取全部测试用例.")
@GetMapping(value="/get") @GetMapping(value = "/get")
public ResponseEntity<List<CaseVo>> get(){ public ResponseEntity<List<CaseVo>> get() {
return ResponseEntity.ok(caseService.findAll()); return ResponseEntity.ok(caseService.findAll());
} }
@ApiOperation(value = "根据测试系统id查询指定测试系统下的所有测试用例.")
@GetMapping(value = "/get/system/{systemId}")
public ResponseEntity<List<CaseVo>> getById(@PathVariable String systemId) {
return ResponseEntity.ok(caseService.findBySystemId(systemId));
}
@ApiOperation(value = "获取单个测试用例.") @ApiOperation(value = "获取单个测试用例.")
@GetMapping(value="/get/{id}") @GetMapping(value = "/get/{id}")
public ResponseEntity<CaseVo> getById(@PathVariable Integer id){ public ResponseEntity<CaseVo> getById(@PathVariable Integer id) {
return ResponseEntity.ok(caseService.findById(id)); return ResponseEntity.ok(caseService.findById(id));
} }
} }
...@@ -24,15 +24,26 @@ public class Case { ...@@ -24,15 +24,26 @@ public class Case {
@GeneratedValue(strategy = GenerationType.IDENTITY) @GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id; private Integer id;
/**
* 所属测试系统id
*/
private String systemId;
/** /**
* 标题 * 标题
*/ */
private String title; private String title;
/** /**
* 浏览器 * 浏览器
*/ */
private String browser; private String browser;
/**
* 运行环境
*/
private String environment;
/** /**
* 起始网站 * 起始网站
*/ */
......
...@@ -18,30 +18,42 @@ public class CaseVo { ...@@ -18,30 +18,42 @@ public class CaseVo {
* 主键 * 主键
*/ */
@ApiModelProperty(value = "主键id",example = "1") @ApiModelProperty(value = "主键id",example = "1")
Integer id; private Integer id;
/**
* 所属测试系统id
*/
@ApiModelProperty(value = "所属测试系统id",example = "40285a81",position = 1)
private String systemId;
/** /**
* 测试用例标题 * 测试用例标题
*/ */
@ApiModelProperty(value = "测试用例标题",example = "百度一下",position = 1) @ApiModelProperty(value = "测试用例标题",example = "百度一下",position = 2)
String title; private String title;
/** /**
* 浏览器 * 浏览器
*/ */
@ApiModelProperty(value = "浏览器",example = "firefox",position = 2) @ApiModelProperty(value = "浏览器",example = "firefox",position = 3)
String browser; private String browser;
/**
* 运行环境
*/
@ApiModelProperty(value = "运行环境",example = "对运行环境的一些描述内容 Win 10/火狐版本 52.0/...",position = 4)
private String environment;
/** /**
* 起始网站 * 起始网站
*/ */
@ApiModelProperty(value = "网站地址",example = "http://www.baidu.com",position = 3) @ApiModelProperty(value = "网站地址",example = "http://www.baidu.com",position = 5)
String url; private String url;
/** /**
* 步骤详情 * 步骤详情
*/ */
@ApiModelProperty(value = "步骤详情",position = 4) @ApiModelProperty(value = "步骤详情",position = 6)
List<Step> steps; private List<Step> steps;
} }
package com.zjty.automatedtesting.pojo.test;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.GenericGenerator;
import javax.persistence.*;
@SuppressWarnings("JpaDataSourceORMInspection")
@Data
@AllArgsConstructor
@NoArgsConstructor
@Entity
@Table(name = "AUTO_TEST_SYSTEM")
@GenericGenerator(name = "jpa-uuid", strategy = "uuid")
public class System {
@Id
@GeneratedValue(generator = "jpa-uuid")
@Column(length = 8)
private String id;
private String name;
}
package com.zjty.automatedtesting.repository;
import com.zjty.automatedtesting.pojo.test.System;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
@Repository
public interface SystemRepository extends JpaRepository<System, String> {
}
...@@ -25,14 +25,20 @@ public interface CaseService { ...@@ -25,14 +25,20 @@ public interface CaseService {
/** /**
* 查询所有测试用例 * 查询所有测试用例
* @return list * @return 测试用例集合
*/ */
List<CaseVo> findAll(); List<CaseVo> findAll();
/**
* 查询指定测试系统下的所有测试用例
* @return 测试用例集合
*/
List<CaseVo> findBySystemId(String systemId);
/** /**
* 指定id查询测试用例 * 指定id查询测试用例
* @param id id * @param id id
* @return testcase * @return 测试用例
*/ */
CaseVo findById(Integer id); CaseVo findById(Integer id);
......
...@@ -2,6 +2,7 @@ package com.zjty.automatedtesting.service; ...@@ -2,6 +2,7 @@ package com.zjty.automatedtesting.service;
import com.zjty.automatedtesting.pojo.report.ReportVo; import com.zjty.automatedtesting.pojo.report.ReportVo;
import com.zjty.automatedtesting.pojo.test.CaseVo; import com.zjty.automatedtesting.pojo.test.CaseVo;
import com.zjty.automatedtesting.service.impl.SeleniumServiceImpl;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
/** /**
......
package com.zjty.automatedtesting.service;
import com.zjty.automatedtesting.pojo.test.System;
import org.springframework.stereotype.Service;
@Service
public interface SystemService {
/**
* 新增测试系统
* 不可附带id
* @return 保存后的测试系统对象
*/
System create(System systemVo);
/**
* 根据id查找测试系统
* @param id 指定id
* @return 查到的测试系统对象
*/
System findById(String id);
}
package com.zjty.automatedtesting.service; package com.zjty.automatedtesting.service.impl;
import com.zjty.automatedtesting.pojo.test.Case; import com.zjty.automatedtesting.pojo.test.Case;
import com.zjty.automatedtesting.pojo.test.CaseVo; import com.zjty.automatedtesting.pojo.test.CaseVo;
import com.zjty.automatedtesting.repository.CaseRepository; import com.zjty.automatedtesting.repository.CaseRepository;
import com.zjty.automatedtesting.service.CaseService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -44,7 +45,17 @@ public class CaseServiceImpl implements CaseService { ...@@ -44,7 +45,17 @@ public class CaseServiceImpl implements CaseService {
@Override @Override
public List<CaseVo> findAll() { public List<CaseVo> findAll() {
return repository.findAll().stream().map(transHelper::toTestCaseVo).collect(Collectors.toList()); return repository.findAll().stream()
.map(transHelper::toTestCaseVo)
.collect(Collectors.toList());
}
@Override
public List<CaseVo> findBySystemId(String systemId) {
return repository.findAll().stream()
.filter(aCase -> Objects.equals(aCase.getSystemId(),systemId))
.map(transHelper::toTestCaseVo)
.collect(Collectors.toList());
} }
@Override @Override
......
package com.zjty.automatedtesting.service; package com.zjty.automatedtesting.service.impl;
import com.zjty.automatedtesting.pojo.report.Report; import com.zjty.automatedtesting.pojo.report.Report;
import com.zjty.automatedtesting.pojo.report.ReportVo; import com.zjty.automatedtesting.pojo.report.ReportVo;
import com.zjty.automatedtesting.repository.ReportRepository; import com.zjty.automatedtesting.repository.ReportRepository;
import com.zjty.automatedtesting.service.ReportService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
......
package com.zjty.automatedtesting.service; package com.zjty.automatedtesting.service.impl;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.zjty.automatedtesting.common.action.Assertion; import com.zjty.automatedtesting.common.action.Assertion;
...@@ -8,6 +8,8 @@ import com.zjty.automatedtesting.pojo.report.Report; ...@@ -8,6 +8,8 @@ import com.zjty.automatedtesting.pojo.report.Report;
import com.zjty.automatedtesting.pojo.report.ReportVo; import com.zjty.automatedtesting.pojo.report.ReportVo;
import com.zjty.automatedtesting.pojo.test.Step; import com.zjty.automatedtesting.pojo.test.Step;
import com.zjty.automatedtesting.pojo.test.CaseVo; import com.zjty.automatedtesting.pojo.test.CaseVo;
import com.zjty.automatedtesting.service.ReportService;
import com.zjty.automatedtesting.service.SeleniumService;
import com.zjty.automatedtesting.util.CommonUtils; import com.zjty.automatedtesting.util.CommonUtils;
import com.zjty.automatedtesting.util.JsonUtil; import com.zjty.automatedtesting.util.JsonUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
......
package com.zjty.automatedtesting.service.impl;
import com.zjty.automatedtesting.pojo.test.System;
import com.zjty.automatedtesting.repository.SystemRepository;
import com.zjty.automatedtesting.service.SystemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import static java.util.Objects.isNull;
@SuppressWarnings("SpringJavaAutowiredFieldsWarningInspection")
@Service
public class SystemServiceImpl implements SystemService {
@Autowired
SystemRepository repository;
@Override
public System create(System system) {
if (isNull(system.getId())) {
return repository.save(system);
}else {
throw new RuntimeException("新增数据不可附带id");
}
}
@Override
public System findById(String id) {
return repository.findById(id).orElseThrow(() -> new RuntimeException("未找到该id的测试系统"));
}
}
package com.zjty.automatedtesting.service; package com.zjty.automatedtesting.service.impl;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.zjty.automatedtesting.pojo.report.Measure; import com.zjty.automatedtesting.pojo.report.Measure;
import com.zjty.automatedtesting.pojo.report.Report; import com.zjty.automatedtesting.pojo.report.Report;
import com.zjty.automatedtesting.pojo.report.ReportVo; import com.zjty.automatedtesting.pojo.report.ReportVo;
import com.zjty.automatedtesting.pojo.test.Step; import com.zjty.automatedtesting.pojo.test.*;
import com.zjty.automatedtesting.pojo.test.Case;
import com.zjty.automatedtesting.pojo.test.CaseVo;
import com.zjty.automatedtesting.util.JsonUtil;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.List; import java.util.List;
...@@ -15,10 +12,11 @@ import java.util.List; ...@@ -15,10 +12,11 @@ import java.util.List;
@Service @Service
public class TransHelper { public class TransHelper {
public Case toTestCase(CaseVo caseVo){ public Case toTestCase(CaseVo caseVo) {
String steps = JsonUtil.toJSon(caseVo.getSteps()); String steps = JSON.toJSONString(caseVo.getSteps());
return new Case( return new Case(
caseVo.getId(), caseVo.getId(),
caseVo.getSystemId(),
caseVo.getTitle(), caseVo.getTitle(),
caseVo.getBrowser(), caseVo.getBrowser(),
caseVo.getUrl(), caseVo.getUrl(),
...@@ -26,10 +24,11 @@ public class TransHelper { ...@@ -26,10 +24,11 @@ public class TransHelper {
); );
} }
public CaseVo toTestCaseVo(Case aCase){ public CaseVo toTestCaseVo(Case aCase) {
List<Step> steps = JsonUtil.readValueToList(aCase.getSteps(),Step.class); List<Step> steps = JSON.parseArray(aCase.getSteps(), Step.class);
return new CaseVo( return new CaseVo(
aCase.getId(), aCase.getId(),
aCase.getSystemId(),
aCase.getTitle(), aCase.getTitle(),
aCase.getBrowser(), aCase.getBrowser(),
aCase.getUrl(), aCase.getUrl(),
...@@ -37,7 +36,7 @@ public class TransHelper { ...@@ -37,7 +36,7 @@ public class TransHelper {
); );
} }
public ReportVo toReportVo(Report report){ public ReportVo toReportVo(Report report) {
List<Measure> measures = JSON.parseArray(report.getMeasures(), Measure.class); List<Measure> measures = JSON.parseArray(report.getMeasures(), Measure.class);
return new ReportVo( return new ReportVo(
report.getId(), report.getId(),
...@@ -47,4 +46,6 @@ public class TransHelper { ...@@ -47,4 +46,6 @@ public class TransHelper {
measures measures
); );
} }
} }
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
自动测试模块是一个独立的微服务。 自动测试模块是一个独立的微服务。
它的作用是对于特定的系统,在特定的运行环境下(包括操作系统、浏览器版本)是否可以正常运作进行自动测试并进行评价 它的作用是对于特定的系统,在特定的运行环境下(包括操作系统、浏览器版本)是否可以正常运作进行自动测试并给出测试结果。
最核心功能,可以概括为3步: 最核心功能,可以概括为3步:
...@@ -20,62 +20,113 @@ ...@@ -20,62 +20,113 @@
以restful接口形式对外提供其功能,数据格式采用json格式。 以restful接口形式对外提供其功能,数据格式采用json格式。
分为2个模块:用户模块、测试模块。
其优点可以概括为以下2点: 其优点可以概括为以下2点:
- 运行环境已经配好,用户可以直接使用。 - 运行环境已经由软件提供方配好,用户可以直接使用。
- 只要配置好测试用例后,一键便可执行整套测试用例完成对系统的测试。 - 只要配置好测试用例后,一键便可执行整套测试用例完成对系统的测试。
### 功能设计 ### 功能设计
功能设计按模块划分。 #### 测试系统
#### 用户模块 ![总览](D:\Documents\黄承天-工作文件\总览.png)
首先展示的是登录页面,可在此进入注册、登录和找回密码。登录成功后在用户的总览操作页面可进行修改密码和退出登录。 总览
##### 登录 ##### 新建测试系统
若已有注册好的账号则可以直接输入用户名、密码进行登录 需要输入系统名,创建后默认打开刚创建的测试系统。系统名和编码在页面右上方显示
##### 注册 ![创建测试系统](D:\Documents\黄承天-工作文件\创建测试系统.png)
注册需要填写的内容有用户名、密码、身份证号、手机号。 ##### 打开测试系统
##### 找回密码 需要输入测试系统编码。打开成功后系统名和编码在页面右上方显示。
方案1:需要填写身份证号、手机号和新密码。确认身份证号和手机无误后即可 打开测试系统后可在页面中配置管理该系统的测试用例,也可以一键执行测试用例
方案2:需要填写身份证号、手机号、验证码和新密码。以确认身份证号无误为前提,进行手机验证码发送的机制。 ![打开测试系统](D:\Documents\黄承天-工作文件\打开测试系统.png)
方案3:需要填写身份证号、手机号、验证码和新密码。以确认身份证号和手机无误为前提,进行生成图片验证码的机制。 #### 测试用例
##### 修改密码 包含一系列自动化的浏览器操作,也就是描述了一个测试过程的数据。一个测试系统下可以有多个测试用例。
需要填写旧密码和新密码,确认旧密码无误后可成功修改为新密码。 ##### 添加测试用例
##### 退出登录 需要填写标题、地址、运行环境并选择浏览器,然后添加测试步骤,最后保存。
退出当前登录的用户。 ![测试用例](D:\Documents\黄承天-工作文件\测试用例.png)
#### 测试模块 ##### 修改测试用例
登录成功后进入该用户的总览操作页面,用户可以在总览页面中看到自己的**测试系统**列表,对自己的**测试系统**进行管理 与添加测试用例相同
##### 打开测试系统 ##### 删除测试用例
删除选中的单个测试用例。
#### 测试步骤
步骤指示了单个的浏览器操作,可以是对某个指定元素的操作,也可以是前进返回之类的无元素操作。在测试用例的编辑窗口中可以对测试步骤进行操作。
##### 添加测试步骤
需要填写标题、操作类型,额外的填写内容视操作类型而不同。可添加或删除断言。
操作类型:有以下4种
- input:对输入框输入文字的操作,需要填写元素的定位方式、定位关键值、输入值。
- click:对按钮的点击操作,需要填写元素的定位方式、定位关键值。
- select:下拉框选择,需要填写元素的定位方式、定位关键值、输入值。
- switch:切换至指定的内置框,需要填写元素的定位方式、定位关键值。
- home:回到起始地址,不需要填写其它值。
另外,元素的定位方式有4种:xpath、id、class、css。其中xpath最为好用且常用。
![测试步骤编辑](D:\Documents\黄承天-工作文件\测试步骤编辑.png)
断言:用于判断操作执行后,页面中某个指定元素的情况是否和预期的一致。断言可以有多个,可添加或删除断言。
添加断言时同样需要填写元素定位方式与定位关键值,为了找到指定的元素。此外还需要填写断言类型。
打开选中的测试系统,可以进行测试用例、测试报告的管理和使用 断言类型有4种:equals、not_equals、exist、not_exist
测试用例:包含一系列自动化的浏览器操作,也就是描述了一套测试过程的数据。需要填写标题、地址并选择运行的浏览器,然后添加测试步骤。测试用例可以添加、修改、删除、执行。也可以一键执行测试系统下的所有测试用例 其中equals和not_equals需要再填写断言键和断言值,判断实际值与断言值是否相等,或者不相等
测试步骤:步骤代表的是一个单独的操作。可以是对页面上某个元素的操作,也可以是不针对元素的返回、前进之类的操作。多个步骤组合起来形成一个测试用例。测试步骤可以在测试用例的详情窗口中添加、修改、删除 而exist和not_exist仅仅是判断指定的元素是否存在,不需要断言键与值
测试报告:由测试用例执行后生成,内容包括测试用例的基本信息以及每个步骤的标题、是否成功的结果、相关信息。每个测试用例所生成的测试报告会被归在这个测试用例下。测试报告可以查看、删除、以html文件形式下载。 ![断言编辑](D:\Documents\黄承天-工作文件\断言编辑.png)
##### 删除测试系统 ##### 编辑测试步骤
删除测试系统的同时会删除其中的所有测试用例和测试报告。 与添加步骤相同,区别在于修改已存在的测试步骤。
##### 删除测试步骤
删除选中的单个测试步骤。
#### 测试报告
由测试用例执行后生成,内容包括测试用例的基本信息以及每个步骤的标题、是否成功的结果、相关信息。每个测试用例所生成的测试报告会被归在这个测试用例下。点击一个测试用例后会显示其具体信息,同时它所产生的测试报告会显示在右边列表中。
##### 查看测试报告
在测试用例执行完毕时,会弹出该次执行所产生的测试报告的详细信息。也可以在列表中点击对应的查看按钮来查看其详细信息。
测试报告会展示该测试用例的标题、地址、运行环境和浏览器,并且会显示每个步骤的序号、标题、结果(是否通过)、相关信息。
![测试报告](D:\Documents\黄承天-工作文件\测试报告.png)
##### 删除测试报告
删除选中的单个测试报告。
##### 下载测试报告
将测试报告以html文件的形式提供下载。
### 使用技术 ### 使用技术
...@@ -156,7 +207,7 @@ has changed to Firefox ≥60. ...@@ -156,7 +207,7 @@ has changed to Firefox ≥60.
IE浏览器的版本对应这个并没有找到具体所对应的版本,**一般用2.5版本**比较好一些(ie11)。 IE浏览器的版本对应这个并没有找到具体所对应的版本,**一般用2.5版本**比较好一些(ie11)。
### 相关接口 ### 相关接口(暂未更新)
#### 概览 #### 概览
...@@ -180,369 +231,7 @@ IE浏览器的版本对应这个并没有找到具体所对应的版本,**一 ...@@ -180,369 +231,7 @@ IE浏览器的版本对应这个并没有找到具体所对应的版本,**一
| /report/delete/{id} | DELETE | 根据id删除单个测试报告 | | /report/delete/{id} | DELETE | 根据id删除单个测试报告 |
| /report/download/{id} | GET | 根据id下载测试报告 | | /report/download/{id} | GET | 根据id下载测试报告 |
详细可在swagger页面中查看和使用
#### 详情
##### 执行测试用例
URL:/testcase/execute
类型:POST
请求数据:
```json
{
"id":1,//主键
"title":"baidu",//标题
"browser": "firefox", //浏览器:谷歌-chrome 火狐-firefox IE-ie
"url": "http://www.baidu.com",//网站地址
"steps": [ //测试步骤集合
{
"order": 1, //步骤序号 从小到大按顺序执行步骤
"title": "输入关键字",//步骤标题
"type": "id", //元素的定位类型:xpath css id name
"key": "kw",//元素的定位关键值
"action": "input", //元素的操作类型 目前有2:input-输入 click-点击
"value": "ty",//输入值 操作为input时需要
"assertion":"value", //判断类型 目前有2:value-当前元素的值 title-页面标题
"expected": "ty" //期望结果
}
{
"order": 2,
"title": "点击搜索按钮",
"type": "id",
"key": "su",
"action": "click",
"assertion":"value",
"expected": "ty"
}
]
}
```
返回数据:
```json
{
"id":1,//主键
"title":"baidu",//标题
"browser": "firefox",//浏览器:谷歌-chrome 火狐-firefox IE-ie
"url": "http://www.baidu.com"//网站地址
"measures": [ //步骤详情
{
"order": 1,//步骤序号
"title": "输入关键字",//步骤标题
"assertion":"value", //判断类型 同测试用例
"expected": "ty", //期望值
"practice": "ty", //实际值
"success": true, //是否成功
"message": "成功." //相关信息
}
{
"order": 2,
"title": "点击搜索按钮",
"assertion":"title",
"expected": "ty",
"practice": "not found",
"success": false,
"message": "失败. 期望:ty. 实际:not found."
}
],
}
```
##### 保存测试用例(不附带id为新增 附带id为修改)
URL:/testcase/save
类型:POST
请求数据:
```json
{
"id":1,//主键
"title":"baidu",//标题
"browser": "firefox", //浏览器:谷歌-chrome 火狐-firefox IE-ie
"url": "http://www.baidu.com",//网站地址
"steps": [ //测试步骤集合
{
"order": 1, //步骤序号 从小到大按顺序执行步骤
"title": "输入关键字",//步骤标题
"type": "id", //元素的定位类型:xpath css id name
"key": "kw",//元素的定位关键值
"action": "input", //元素的操作类型 目前有2:input-输入 click-点击
"value": "ty",//输入值 操作为input时需要
"assertion":"value", //判断类型 目前有2:value-当前元素的值 title-页面标题
"expected": "ty" //期望结果
}
{
"order": 2,
"title": "点击搜索按钮",
"type": "id",
"key": "su",
"action": "click",
"assertion":"value",
"expected": "ty"
}
]
}
```
返回数据:
```json
{
"message","success"
}
```
##### 获取所有测试用例
URL:/testcase/get
类型:GET
请求数据:无
返回数据:
```json
[
{
"id":1,//主键
"title":"baidu",//标题
"browser": "firefox", //浏览器:谷歌-chrome 火狐-firefox IE-ie
"url": "http://www.baidu.com",//网站地址
"steps": [ //测试步骤集合
{
"order": 1, //步骤序号 从小到大按顺序执行步骤
"title": "输入关键字",//步骤标题
"type": "id", //元素的定位类型:xpath css id name
"key": "kw",//元素的定位关键值
"action": "input", //元素的操作类型 目前有2:input-输入 click-点击
"value": "ty",//输入值 操作为input时需要
"assertion":"value", //判断类型 目前有2:value-当前元素的值 title-页面标题
"expected": "ty" //期望结果
}
{
"order": 2,
"title": "点击搜索按钮",
"type": "id",
"key": "su",
"action": "click",
"assertion":"value",
"expected": "ty"
}
]
}
]
```
##### 根据id获取单个测试用例
URL:/testcase/get/{id}
类型:GET
请求数据:附带在url中
返回数据:
```json
{
"id":1,//主键
"title":"baidu",//标题
"browser": "firefox", //浏览器:谷歌-chrome 火狐-firefox IE-ie
"url": "http://www.baidu.com",//网站地址
"steps": [ //测试步骤集合
{
"order": 1, //步骤序号 从小到大按顺序执行步骤
"title": "输入关键字",//步骤标题
"type": "id", //元素的定位类型:xpath css id name
"key": "kw",//元素的定位关键值
"action": "input", //元素的操作类型 目前有2:input-输入 click-点击
"value": "ty",//输入值 操作为input时需要
"assertion":"value", //判断类型 目前有2:value-当前元素的值 title-页面标题
"expected": "ty" //期望结果
}
{
"order": 2,
"title": "点击搜索按钮",
"type": "id",
"key": "su",
"action": "click",
"assertion":"value",
"expected": "ty"
}
]
}
```
##### 根据id删除单个测试用例
URL:/testcase/delete/{id}
类型:DELETE
请求数据:附带在url中
返回数据:
```json
{
"message","success"
}
```
##### 获取所有测试报告
URL:/report/get
类型:GET
请求数据:无
返回数据:
```json
[
{
"id":1,//主键
"title":"baidu",//标题
"browser": "firefox",//浏览器:谷歌-chrome 火狐-firefox IE-ie
"url": "http://www.baidu.com"//网站地址
"measures": [ //步骤详情
{
"order": 1,//步骤序号
"title": "输入关键字",//步骤标题
"assertion":"value", //判断类型 同测试用例
"expected": "ty", //期望值
"practice": "ty", //实际值
"success": true, //是否成功
"message": "成功." //相关信息
}
{
"order": 2,
"title": "点击搜索按钮",
"assertion":"title",
"expected": "ty",
"practice": "not found",
"success": false,
"message": "失败. 期望:ty. 实际:not found."
}
],
}
]
```
##### 根据测试用例id获取所属测试报告
URL:/report/get/case/{caseId}
类型:GET
请求数据:附带在url中
返回数据:
```json
[
{
"id":1,//主键
"title":"baidu",//标题
"browser": "firefox",//浏览器:谷歌-chrome 火狐-firefox IE-ie
"url": "http://www.baidu.com"//网站地址
"measures": [ //步骤详情
{
"order": 1,//步骤序号
"title": "输入关键字",//步骤标题
"assertion":"value", //判断类型 同测试用例
"expected": "ty", //期望值
"practice": "ty", //实际值
"success": true, //是否成功
"message": "成功." //相关信息
}
{
"order": 2,
"title": "点击搜索按钮",
"assertion":"title",
"expected": "ty",
"practice": "not found",
"success": false,
"message": "失败. 期望:ty. 实际:not found."
}
],
}
]
```
#####
##### 根据id获取单个测试报告
URL:/report/get/{id}
类型:GET
请求数据:附带在url中
```json
{
"id":1,//主键
"title":"baidu",//标题
"browser": "firefox",//浏览器:谷歌-chrome 火狐-firefox IE-ie
"url": "http://www.baidu.com"//网站地址
"measures": [ //步骤详情
{
"order": 1,//步骤序号
"title": "输入关键字",//步骤标题
"assertion":"value", //判断类型 同测试用例
"expected": "ty", //期望值
"practice": "ty", //实际值
"success": true, //是否成功
"message": "成功." //相关信息
}
{
"order": 2,
"title": "点击搜索按钮",
"assertion":"title",
"expected": "ty",
"practice": "not found",
"success": false,
"message": "失败. 期望:ty. 实际:not found."
}
],
}
```
##### 根据id删除单个测试报告
URL:/report/delete/{id}
类型:DELETE
请求数据:附带在url中
返回数据:
```json
{
"message","success"
}
```
##### 根据id下载测试报告
URL:/report/download/{id}
类型:GET
请求数据:附带在url中
返回数据:文件输出流
### 更新记录 ### 更新记录
...@@ -553,6 +242,7 @@ URL:/report/download/{id} ...@@ -553,6 +242,7 @@ URL:/report/download/{id}
- 2020.2.20:增加下载测试报告的功能。以html文件的形式提供下载。 - 2020.2.20:增加下载测试报告的功能。以html文件的形式提供下载。
- 2020.2.24:测试用例执行结束后自动关闭浏览器。增加接口根据测试用例的id查询其所属的测试报告。预期属性改变为可选项,若没有预期属性则会低限度的以是否出现异常来判断步骤是否成功。 - 2020.2.24:测试用例执行结束后自动关闭浏览器。增加接口根据测试用例的id查询其所属的测试报告。预期属性改变为可选项,若没有预期属性则会低限度的以是否出现异常来判断步骤是否成功。
- 2020.2.25:修复Chrome驱动无法运行的问题。判断预期结果前和每个步骤执行后会等待2秒以保证结果更精准。 - 2020.2.25:修复Chrome驱动无法运行的问题。判断预期结果前和每个步骤执行后会等待2秒以保证结果更精准。
- 2020.2.28:完成测试系统这一块相关功能接口:增加测试系统的新增和查询接口;增加根据测试系统id查询测试用例的接口;增加根据测试系统id批量执行其所有测试用例的接口。
### 遗留问题 ### 遗留问题
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论