亚洲好骚综合-亚洲黄色录像-亚洲黄色网址-亚洲黄色网址大全-99久久99久久-99久久99久久精品国产

您的位置:軟件測試 > 開源軟件測試 > 開源單元測試工具 > junit
《項目架構那點兒事》?快速構建Junit用例
作者:網絡轉載 發布時間:[ 2015/11/4 14:22:15 ] 推薦標簽:單元測試 軟件測試工具

  二、編寫SpringJunit(依賴包:spring-test-3.0.4.RELEASE.jar,junit4,以及其他的spring核心包),還是以User為例子,我們編寫UserTestUnit來驗證我們后臺的方法,如下:
/**
* @author fisher
* @description 用戶業務測試
*/
// 使用springJunit4
@RunWith(SpringJUnit4ClassRunner.class)
// spring配置文件加載(locations為文件路徑)
@ContextConfiguration(locations = {
"classpath:spring/application-hibernate.xml",
"classpath:spring/application-common-service.xml",
"classpath:spring/application-sys-service.xml" })
public class UserTestJunit {
@Autowired
UserService userService;// 自動注入userService
/**
* @description 測試查詢用戶
* @throws Exception
*/
@Test
public void query() throws Exception {
List result = userService.getAllEmployee();
Assert.notEmpty(result);
}
/**
* @description 測試用戶添加
* @throws Exception
*/
@Test
public void save() throws Exception {
User user = new User();
user.setUsrCode("test001");
user.setUsrName("test");
user.setPassword("123");
user.setIdCard("513029198503140026");
user.setEmail("aaa@sina.com");
User u = userService.save(user);
Assert.notNull(u);
org.junit.Assert.assertEquals("test", user.getUsrName());
}
/**
* @description 測試用戶更新
* @throws Exception
*/
@Test
public void update() throws Exception {
User user = new User();
user.setUsrCode("test001");
user.setUsrName("test");
user.setPassword("123");
user.setIdCard("513029198503140026");
user.setEmail("aaa@sina.com");
User u = userService.update(user);
Assert.notNull(u);
org.junit.Assert.assertEquals("test", user.getUsrName());
}
/**
* @description 測試用戶刪除
* @throws Exception
*/
@Test
public void del() throws Exception {
User user = new User();
user.setUserId("1");
User u = userService.delete(user);
Assert.notNull(u);
org.junit.Assert.assertEquals("1", user.getUserId());
}
}
  【總結】單元測試不于此,靈活性比較大,要結合實際進行編寫,上面兩種測試是按照我們項目中規范編寫,大家可以作為參考,自我覺得還是比較實用而且用注解方式比較方便。

上一頁12下一頁
軟件測試工具 | 聯系我們 | 投訴建議 | 誠聘英才 | 申請使用列表 | 網站地圖
滬ICP備07036474 2003-2017 版權所有 上海澤眾軟件科技有限公司 Shanghai ZeZhong Software Co.,Ltd
主站蜘蛛池模板: 无遮挡h黄漫动漫在线观看 无遮挡h纯内动漫在线观看 | 欧美亚洲专区 | 最近更新中文字幕影视 | 午夜视频在线看 | 日韩中文字幕在线免费观看 | 高清中文字幕 | 免费一级录像 | 2020久久精品国产免费 | 一级黄色录像视频 | 亚洲精品中文字幕久久久久久 | 久久天天躁狠狠躁夜夜不卡 | 黄色网址免费看 | 欧美特级黄色片 | 女人洗澡一级特黄毛片 | 国产一精品一av一免费爽爽 | 色噜噜狠狠色综合欧洲 | 免费在线看黄网站 | 欧美精彩视频在线观看 | 最近2019中文 | 成人男女网18免费视频 | 狠狠干五月 | 国产精品人成在线播放新网站 | 亚洲美女操 | 国产1区2区在线观看 | 青青青视频免费一区二区 | 天天摸天天做天天爽 | 在线免费亚洲 | 成人免费v片在线观看 | 黄免费在线观看 | 天天综合网色 | 国产精品人人视频 | 亚洲精品亚洲人成在线观看麻豆 | 精品区卡一卡2卡三免费 | a级毛片黄 | 日日摸夜夜摸狠狠摸日日碰夜夜做 | 久久国产精品亚洲一区二区 | 日韩精品一区二区三区四区 | 一级特黄视频 | 2018天天夜夜| 日韩精品一区二区三区 在线观看 | 欧美精品一区二区精品久久 |