Spring MVC 单元测试
来源:互联网 发布:sql server 2017 收费 编辑:程序博客网 时间:2024/05/17 06:42
package com.zzy.wyxtools.user.controller;import com.zzy.SysApplication;import junit.framework.TestCase;import org.junit.After;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.SpringApplicationConfiguration;import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;import org.springframework.test.context.transaction.TransactionConfiguration;import org.springframework.test.context.web.WebAppConfiguration;import org.springframework.test.web.servlet.MockMvc;import org.springframework.test.web.servlet.setup.MockMvcBuilders;import org.springframework.web.context.WebApplicationContext;import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.*;import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;import javax.transaction.Transactional;@RunWith(SpringJUnit4ClassRunner.class)@WebAppConfiguration@SpringApplicationConfiguration(classes = SysApplication.class)//当然 你可以声明一个事务管理 每个单元测试都进行事务回滚 无论成功与否@TransactionConfiguration(defaultRollback = true)@Transactionalpublic class IndexControllerTest extends TestCase { @Autowired private WebApplicationContext wac; private MockMvc mockMvc; @Before public void setUp() throws Exception { this.mockMvc = MockMvcBuilders.webAppContextSetup(this.wac).build(); } @After public void tearDown() throws Exception { } @Test public void testIndex() throws Exception { mockMvc.perform((post("/login").param("abc", "def"))) .andExpect(status().isOk()).andDo(print()); mockMvc.perform((post("/index").param("abc", "def"))) .andExpect(status().isOk()).andDo(print()); } @Test public void testGetBaseUrl() throws Exception { } @Test public void testGetRequest() throws Exception { } @Test public void testGetResponse() throws Exception { } @Test public void testRenderValidateImg() throws Exception { } @Test public void testSaveSysUserToSession() throws Exception { } @Test public void testRemoveSysUserSession() throws Exception { } @Test public void testGetCurrentSysUser() throws Exception { } @Test public void testValidPassword() throws Exception { } @Test public void testEntryptPassword() throws Exception { } @Test public void testPageParamResolve() throws Exception { } @Test public void testSaveQueryInfoAndReturnPage() throws Exception { } @Test public void testSaveQueryInfoAndReturnPage1() throws Exception { } @Test public void testSaveRequestParameter() throws Exception { } @Test public void testBackList() throws Exception { } @Test public void testSaveSysActionLog() throws Exception { } @Test public void testGetCurrentUser() throws Exception { } @Test public void testQuotaChange() throws Exception { } @Test public void testQuotaChange1() throws Exception { }}
阅读全文
0 0
- Spring MVC自动化单元测试
- Spring MVC自动化单元测试
- Spring MVC自动化单元测试
- Spring MVC自动化单元测试
- Spring MVC自动化单元测试
- Spring MVC自动化单元测试
- Spring MVC自动化单元测试
- Spring MVC自动化单元测试
- Spring MVC自动化单元测试
- Spring MVC自动化单元测试
- Spring MVC自动化单元测试
- Spring MVC自动化单元测试
- Spring MVC自动化单元测试
- Spring MVC自动化单元测试
- Spring MVC自动化单元测试
- Spring MVC自动化单元测试
- Spring MVC自动化单元测试
- Spring MVC 单元测试
- Java实例-Swing简易计算器(加,减,乘,数)
- 登录oracle数据库时常用的操作命令整理
- java中map里面的key按我们插入进去的顺序输出
- Maven学习总结(4)——Maven核心概念
- 专家预测,未来将是大数据可视化当道
- Spring MVC 单元测试
- docker 初接触
- CAFFE2中C++11实现的线程池
- Java基础编程1—完数
- angularjs之ng file upload
- 霍夫变换直线检测基本原理hough,houghpeaks,houghlines
- MySql--存储引擎、索引、视图、DBA命令
- ORA-32773
- C++primer学习笔记-----6.7函数指针