junit基础学习之-参数初始化(5)
2024-09-06 06:09:40
package swust.edu.cn.postdoctors.service.impl; import java.util.Arrays;
import java.util.Collection; import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;
import org.springframework.test.context.ContextConfiguration; import swust.edu.cn.postdoctors.model.User;
import swust.edu.cn.postdoctors.service.UserService;
import junit.framework.TestCase; @RunWith(Parameterized.class)
@ContextConfiguration(locations={"classpath:spring-mybatis-test.xml"}) // 加载配置
public class UserServiceTest extends TestCase { private UserService userService; public UserService getUserService() {
return userService;
} public void setUserService(UserService userService) {
this.userService = userService;
} @Parameters
public static Collection<Object[]> data(){
return Arrays.asList(new Object[][]{{"aa",""},{"bb",""},{"cc",""}});
}
private String userLoginname;
private String userPswd; public UserServiceTest(String userLoginname,String userPswd){
this.setUserLoginname(userLoginname);
this.setUserPswd(userPswd);
} public String getUserLoginname() {
return userLoginname;
} public void setUserLoginname(String userLoginname) {
this.userLoginname = userLoginname;
} public String getUserPswd() {
return userPswd;
} public void setUserPswd(String userPswd) {
this.userPswd = userPswd;
} @Before
public void before() throws Exception {
userService = new UserServiceImpl();
} @Test
public void testSelectUserByLoginNameAndPswd() throws Exception {
if(userService == null){
System.out.println("========================userService 出错!");
}
User exUser = new User();
exUser.setUserLoginname(userLoginname);
exUser.setUserPassword(userPswd); User outUser = null; outUser = userService.findUserByLoginNameAndPswd(userLoginname, userPswd); assertEquals(exUser,outUser); } }
最新文章
- SQL语句全
- 可提高工作效率的 PL/SQL Developer 设置
- Windows 磁盘检查命令
- JavaScript包装对象
- webservice入门(2)开发ws程序
- 加州大学伯克利分校Stat2.3x Inference 统计推断学习笔记: Section 3 One-sample and two-sample tests
- struts.xml配置
- VBA的打开关闭保存另存为等事件无法正常跑的原因
- 545E. Paths and Trees
- javascript获取对应页面的代码
- Bootstrap 简洁、直观、强悍、移动设备优先的前端开发框架,让web开发更迅速、简单。
- C#递归复制文件夹
- FCKeditor 2.6.6在ASP中的安装及配置方法分享--ZZ转载自网络
- POJ1050(dp)
- Angular+ionic2 web端 启动程序出现短暂 白屏或黑屏 的处理小妙招
- Java开发笔记(八十五)通过字符流读写文件
- lintcode中等题目的四道题
- day02 while循环 运算符 格式化输出 编码
- Luogu2839 Middle 主席树、二分答案
- mvc 缓存页面 减轻服务器压力