更新数据库出现问题java.lang.AssertionError: expected:<1> but was:<0>

运行测试案例,看到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);
    }

与数据库对应后再运行。稳了。

posted @ 2019-04-22 22:01  孤独幻旅  阅读(5618)  评论(0编辑  收藏  举报