@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);}}