当前位置: 首页 > news >正文

查询网站备案做网站封面要怎么做

查询网站备案,做网站封面要怎么做,河南中国建设厅官方网站,重庆seo推广springboot虚拟请求 表现层测试 web环境模拟测试 虚拟请求状态匹配——执行状态的匹配 Testvoid testStatus(Autowired MockMvc mvc) throws Exception { // //http://localhost:8080/books// 创建一个虚拟请求,当前访问的是booksMockHttpServletRequestBui…

springboot虚拟请求

表现层测试

web环境模拟测试

在这里插入图片描述
在这里插入图片描述

虚拟请求状态匹配——执行状态的匹配

    @Testvoid testStatus(@Autowired MockMvc mvc) throws Exception {
//       //http://localhost:8080/books// 创建一个虚拟请求,当前访问的是booksMockHttpServletRequestBuilder builder = MockMvcRequestBuilders.get("/books1");ResultActions actions = mvc.perform(builder);//设定预期值,与真实值进行比较,成功测试通过,失败测试失败// 定义本次调用的预期值StatusResultMatchers status = MockMvcResultMatchers.status();// 预计本次调用时成功的状态200ResultMatcher ok = status.isOk();// 添加与机制到本次调用过程中进行匹配actions.andExpect(ok);}

虚拟请求状态匹配——执行内容的匹配

   @Testvoid testBody(@Autowired MockMvc mvc) throws Exception {
//       //http://localhost:8080/books// 创建一个虚拟请求,当前访问的是booksMockHttpServletRequestBuilder builder = MockMvcRequestBuilders.get("/books");ResultActions actions = mvc.perform(builder);//设定预期值,与真实值进行比较,成功测试通过,失败测试失败// 定义本次调用的预期值ContentResultMatchers content = MockMvcResultMatchers.content();ResultMatcher result = content.string("springboot");// 添加与机制到本次调用过程中进行匹配actions.andExpect(result);}

虚拟请求状态匹配——执行内容的匹配(json)

 @Testvoid testJson(@Autowired MockMvc mvc) throws Exception {MockHttpServletRequestBuilder builder = MockMvcRequestBuilders.get("/books");ResultActions actions = mvc.perform(builder);//设定预期值,与真实值进行比较,成功测试通过,失败测试失败// 定义本次调用的预期值ContentResultMatchers content = MockMvcResultMatchers.content();ResultMatcher result = content.json("{\n" +"    \"id\": 1,\n" +"    \"name\": \"springBoot\",\n" +"    \"type\": \"springBoot\",\n" +"    \"description\": \"springBoot\"\n" +"}");// 添加与机制到本次调用过程中进行匹配actions.andExpect(result);}

在这里插入图片描述

这里面的东西都可以匹配

虚拟请求状态匹配——匹配响应头

@Testvoid testContentType(@Autowired MockMvc mvc) throws Exception {MockHttpServletRequestBuilder builder = MockMvcRequestBuilders.get("/books");ResultActions actions = mvc.perform(builder);//设定预期值,与真实值进行比较,成功测试通过,失败测试失败// 定义本次调用的预期值HeaderResultMatchers header = MockMvcResultMatchers.header();ResultMatcher contentType = header.string("Content-Type","application/json");// 添加与机制到本次调用过程中进行匹配actions.andExpect(contentType);}

实际应用的时候,可以把这些都放在一起
例如,把这些组合一下:

@Testvoid testGetById(@Autowired MockMvc mvc) throws Exception {MockHttpServletRequestBuilder builder = MockMvcRequestBuilders.get("/books");ResultActions actions = mvc.perform(builder);StatusResultMatchers status = MockMvcResultMatchers.status();ResultMatcher ok = status.isOk();actions.andExpect(ok);HeaderResultMatchers header = MockMvcResultMatchers.header();ResultMatcher contentType = header.string("Content-Type","application/json");actions.andExpect(contentType);ContentResultMatchers content = MockMvcResultMatchers.content();ResultMatcher result = content.json("{\n" +"    \"id\": 1,\n" +"    \"name\": \"springBoot\",\n" +"    \"type\": \"springBoot2\",\n" +"    \"description\": \"springBoot\"\n" +"}");actions.andExpect(result);}

数据层测试事务回滚

在这里插入图片描述

测试用例数据设定

在这里插入图片描述
配置一个对象来使用,比如:

package com.itheima.testcase.domain;import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;@Data
@Component
@ConfigurationProperties(prefix = "testcase.book")
public class BookCase {private int id;private int id2;private int type;private String name;private  String uuid;private long publishTime;
}
http://www.yayakq.cn/news/589286/

相关文章:

  • 贵阳专业做网站公司有哪些济宁网站制作唐人
  • 网站流水怎么做珠海网站策划
  • 萧山网站建设公司广州网站设计我选刻
  • 2个网站做的链接怎么用一个域名免费的域名网址
  • 云建站的步骤怎样给网站做
  • 哈尔滨优惠的网站建设wordpress自带图片大小
  • 做ppt的网站叫什么名字天津网站建设制作方案
  • 做go分析和kegg分析网站软件开发分为哪几类
  • 太原网站建设丿薇电子商务网站规划方案
  • 软件开发网站wordpress 上传文件
  • 淘宝客怎么样做网站互联网 网站建设
  • 电脑做网站服务器需要什么软件mg动画制作
  • 网站建设的公司上海石家庄手机建网站
  • 西安做网站哪家便宜0元建设黑网站
  • dedecms如何做音乐网站网站评估怎么做
  • 牌具做网站可以吗工控机软件开发工具
  • 免费网站制作平台下载电子书制作公司网站
  • 网站推广平台排行网站推广公司 wordpress
  • 搜索引擎网站推广可以自己做吗计算机网站建设及管理
  • 禹城网站设计住建厅特种作业证全国通用吗
  • 网站建设公司倒闭wordpress 大前端 插件
  • 上海网站建设最好的公司温州网站建设公司哪个好
  • 重庆网站自己推广程序开发用什么笔记本
  • 域名注册好了如何做网站帝国cms做企业网站
  • 建设银行网站安全分析石岩网站建设公司
  • 山西有哪些做网站的公司wordpress主题 demo
  • 网店推广新技术网站网络优化
  • 网上智慧团建网站wordpress ftp设置方法
  • 代做网站公司织梦做的网站有点慢
  • 库尔勒网站佛山手工活外发加工网