運行測試案例,看到errors為0,還以為穩了,結果看數據庫信息,卻沒有更新。
回來查看,
出現問題java.lang.AssertionError: expected:<1> but was:<0>
console信息如下:
2019-04-22 21:30:18.710 [main] DEBUG com.imooc.o2o.dao.ShopDao.updateShop - ==> Preparing: update tb_shop SET shop_name=?, shop_desc=?, shop_addr=?, last_edit_time=? where shop_id=?
2019-04-22 21:30:18.753 [main] DEBUG com.imooc.o2o.dao.ShopDao.updateShop - ==> Parameters: 測試的店鋪(String), 測試描述(String), 測試地址(String), 2019-04-22 21:30:18.255(Timestamp), 1(Long)
2019-04-22 21:30:18.753 [main] DEBUG com.imooc.o2o.dao.ShopDao.updateShop - <== Updates: 0
又查看了測試案例和數據庫,發現測試案例中的字段在數據庫中並沒有出現。修改了測試案例,
@Test public void testUpdateShop() { Shop shop = new Shop(); shop.setShopId(1L); shop.setShopName("測試的店鋪"); shop.setShopDesc("測試描述"); shop.setShopAddr("測試地址"); shop.setLastEditTime(new Date()); int effectedNum = shopDao.updateShop(shop); assertEquals(1, effectedNum); }
與數據庫對應后再運行。穩了。