亚洲好骚综合-亚洲黄色录像-亚洲黄色网址-亚洲黄色网址大全-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
主站蜘蛛池模板: 最近最新的日本免费 | 亚洲一区二区三区精品影院 | 男女性激烈动态图无遮挡 | 成年美女xx网站高清视频 | 国产丫丫视频私人影院 | 秋霞影视伦理手机在线观看 | 亚洲怡春院 | 久久91亚洲精品中文字幕 | 蜜臀91精品国产高清在线观看 | 日韩欧国产精品一区综合无码 | 国产午夜精品一区二区 | 日韩在线视频观看 | 新26uuu在线亚洲欧美 | 欧美日韩国产一区二区三区不卡 | 国内精品区一区二区三 | 韩日欧美| 激情五月宗合网 | 激情综合欧美 | 女人被男人扒开狂躁视频 | 激情五月深爱五月 | 在线小视频你懂的 | 丝袜足控免费网站 | 午夜视频在线观看完整高清在线 | 小明天天看成人免费看 | 最近免费中文字幕大全视频 | a级毛片黄色 | 国产亚洲综合色就色 | 日本欧美一区二区 | 中文字幕亚洲无线码在线一区 | 成人性生交大片免费看午夜a | 涩涩网址 | 国内精品久久久久久影院老狼 | 久久综合久久精品 | 亚洲欧美精品一区天堂久久 | 欧美不卡一区 | 99视频精品全部国产盗摄视频 | 香蕉精品一本大道在线观看 | 亚洲第一视频网 | 最近中文字幕完整视频大全版 | 一级黄色片免费观看 | 国产成人在线观看免费网站 |