@Testpublicvoidinsert(){User user =newUser();user.setId(6L);user.setName("张三");user.setAge(25);user.setEmail("zhangsan@example.com");userMapper.insert(user);}
@TestpublicvoidupdateById(){User user =newUser();user.setId(6L);user.setAge(28);user.setEmail("zhangsan28@example.com");userMapper.updateById(user);}
日志
数据库数据
查询一条数据
代码
@Testpublicvoidselect(){User user = userMapper.selectById(6);System.out.println(user);}
日志
数据库数据
全部测试代码
packagecom.example;importcom.example.web.entity.User;importcom.example.web.mapper.UserMapper;importorg.junit.jupiter.api.Test;importorg.springframework.beans.factory.annotation.Autowired;importorg.springframework.boot.test.context.SpringBootTest;@SpringBootTestclassMapperTest{@AutowiredprivateUserMapper userMapper;@Testpublicvoidinsert(){User user =newUser();user.setId(6L);user.setName("张三");user.setAge(25);user.setEmail("zhangsan@example.com");userMapper.insert(user);}@Testpublicvoiddelete(){userMapper.deleteById(6);}@TestpublicvoidupdateById(){User user =newUser();user.setId(6L);user.setAge(28);user.setEmail("zhangsan28@example.com");userMapper.updateById(user);}@Testpublicvoidselect(){User user = userMapper.selectById(6);System.out.println(user);}}
🌷🍁 博主猫头虎(🐅🐾)带您 Go to New World✨🍁 🦄 博客首页——🐅🐾猫头虎的博客🎐 🐳 《面试题大全专栏》 🦕 文章图文…