更新数据库出现问题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);
    }

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


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM