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

产品网站建设找哪家百度关键词优化有效果吗

产品网站建设找哪家,百度关键词优化有效果吗,易语言可以做网站嘛,网站搭建软件工具一、前言知识 1.开发过程 需求分析->设计->开发->测试->上线 2.测试种类 单元测试(测试模块编码)、黑盒测试(测试功能是否满足需求)、白盒测试(测试程序内部的逻辑结构)、回归测试(提出的缺陷进行二次验证)、集成测试(测试主要的业务功能及模块间的整合性)、系…

一、前言知识

1.开发过程

需求分析->设计->开发->测试->上线

2.测试种类

单元测试(测试模块编码)、黑盒测试(测试功能是否满足需求)、白盒测试(测试程序内部的逻辑结构)、回归测试(提出的缺陷进行二次验证)、集成测试(测试主要的业务功能及模块间的整合性)、系统测试(测试整个产品系统)

二、单元测试的使用

1.引入相关依赖

<!-- 单元测试的依赖--><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-test</artifactId><scope>test</scope><exclusions><exclusion><groupId>org.junit.vintage</groupId><artifactId>junit-vintage-engine</artifactId></exclusion></exclusions></dependency><dependency><groupId>junit</groupId><artifactId>junit</artifactId><version>4.12</version><scope>test</scope></dependency>

2.编写单元测试方法

断言:判断程序结果是否符合预期 TestCase.assertXXX

package net.xdclass.demoproject;import junit.framework.TestCase;
import net.xdclass.demoproject.domain.Video;
import net.xdclass.demoproject.service.VideoService;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.MvcResult;
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
import org.springframework.test.web.servlet.result.MockMvcResultMatchers;import java.nio.charset.Charset;
import java.util.List;//1.配置
@RunWith(SpringRunner.class)  //底层用junit  SpringJUnit4ClassRunner
@SpringBootTest(classes={DemoProjectApplication.class})//启动整个springboot工程
@AutoConfigureMockMvc
public class VideoTest {@Autowired//会自动将VideoService对象注入到VideoTest对象中,相当于new VideoService()private VideoService videoService;//2.常用注解的使用@Before//在测试用例执行前执行public void testOne(){System.out.println("这个是测试 before");}@Test//测试用例public void testVideoList(){List<Video> videoList = videoService.listVideo();//判断videoList的大小是否大于0,如果大于0,则测试通过,如果小于0,则测试失败TestCase.assertTrue(videoList.size()>0);}@After//在测试用例执行后执行public void testThree(){System.out.println("这个是测试 after");}}

三、单元测试的应用

1.测试controller层登录方法

UserTest

package net.xdclass.demoproject;import junit.framework.TestCase;
import net.xdclass.demoproject.controller.UserController;
import net.xdclass.demoproject.domain.User;
import net.xdclass.demoproject.utils.JsonData;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;@RunWith(SpringRunner.class)  //底层用junit  SpringJUnit4ClassRunner
@SpringBootTest(classes={DemoProjectApplication.class})//启动整个springboot工程
public class UserTest {@Autowiredprivate UserController userController;@Testpublic void loginTest(){//模拟前端传递过来的参数User user = new User();user.setUsername("jack");user.setPwd("1234");//调用controller的login方法JsonData jsonData  = userController.login(user);//打印返回的json数据System.out.println(jsonData.toString());//断言TestCase.assertEquals(0,jsonData.getCode());}
}

2.测试service层视频列表

VideoTest

package net.xdclass.demoproject;import junit.framework.TestCase;
import net.xdclass.demoproject.domain.Video;
import net.xdclass.demoproject.service.VideoService;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.MvcResult;
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
import org.springframework.test.web.servlet.result.MockMvcResultMatchers;import java.nio.charset.Charset;
import java.util.List;@RunWith(SpringRunner.class)  //底层用junit  SpringJUnit4ClassRunner
@SpringBootTest(classes={DemoProjectApplication.class})//启动整个springboot工程
public class VideoTest {@Autowired//会自动将VideoService对象注入到VideoTest对象中,相当于new VideoService()private VideoService videoService;@Test//测试用例public void testVideoList(){List<Video> videoList = videoService.listVideo();//判断videoList的大小是否大于0,如果大于0,则测试通过,如果小于0,则测试失败TestCase.assertTrue(videoList.size()>0);}}

3.测试对外提供的接口

 VideoTest

package net.xdclass.demoproject;import junit.framework.TestCase;
import net.xdclass.demoproject.domain.Video;
import net.xdclass.demoproject.service.VideoService;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.MvcResult;
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
import org.springframework.test.web.servlet.result.MockMvcResultMatchers;import java.nio.charset.Charset;
import java.util.List;@RunWith(SpringRunner.class)  //底层用junit  SpringJUnit4ClassRunner
@SpringBootTest(classes={DemoProjectApplication.class})//启动整个springboot工程
@AutoConfigureMockMvc//自动注入MockMvc对象,用于模拟请求
public class VideoTest {@Autowired//会自动将VideoService对象注入到VideoTest对象中,相当于new VideoService()private VideoService videoService;@Autowiredprivate MockMvc mockMvc;//模拟请求@Test//测试用例public void testVideoListApi()throws Exception{//模拟请求:会返回一个MvcResult对象,里面包含了响应的状态码,响应的内容MvcResult mvcResult =  mockMvc.perform(MockMvcRequestBuilders.get("/api/v1/pub/video/list"))//访问接口的地址.andExpect(MockMvcResultMatchers.status().isOk()).andReturn();int status = mvcResult.getResponse().getStatus();//获取响应的状态码System.out.println(status);// 使用下面这个,增加编码说明,就不会乱码打印String result = mvcResult.getResponse().getContentAsString(Charset.forName("utf-8"));System.out.println(result);}
}

四、小结 

          单元测试的实质就是通过加入测试工具依赖,然后使用注释和断言来配合验证不同取值下功能模块的输出结果与预期结果是否一致。

 

http://www.dtcms.com/wzjs/20512.html

相关文章:

  • 免费炫酷企业网站源码利于seo的建站系统有哪些
  • 网站建设发票能抵扣增值税项目营销推广方案
  • 网站目录 整理专业seo培训学校
  • 青县有做网站的吗百度竞价登陆
  • 一个人看的片免费高清大全seo营销推广平台
  • 手机网站大全1长沙网站优化方法
  • 网站短信接口怎么做网络营销的六大功能
  • 如何请人做网站安卓系统最好优化软件
  • 百度网盘做网站网页广告怎么做
  • wordpress建站有广告吗深圳网络推广优化
  • 网站哪些数据seo挂机赚钱
  • 上海网站制作公司哪家北京seo运营推广
  • 做化工的有哪些网站域名查询
  • 网站培训搜索引擎调价工具哪个好
  • 网站开发公司所需投入资源网络服务提供商是指
  • 阿里云个人怎么免费做网站seo网络推广企业
  • webform做网站 适应屏幕大小短视频运营是做什么的
  • 做电影售票网站的难点上海站群优化公司
  • 网站页面改版降权广州seo排名优化服务
  • 徐州网站建设培训班免费外链发布平台
  • 怎样创立一个网站网页制作代码
  • 自己开个网站seo咨询推广找推推蛙
  • wordpress 主题banner宁波seo快速排名
  • 众享城市生活app缴费seo自然优化排名技巧
  • 太原网站建设费用网站运营工作内容
  • 广州微信网站建设咨询如何提升百度关键词排名
  • 网站百度品牌搜索引擎服务优化
  • 纯html静态网站产品seo怎么优化
  • qq浏览器网页版入口seo建站技巧
  • 自己做的网站提示不安全吗免费域名怎么注册