业务层测试数据回滚
我们之前在写dao层
测试的时候
如果执行到这边的代码 会在数据库 里面留下数据
运行一次留一次数据


开发有开发数据库,运行有运行数据库
我们先连数据库

在pom文件里引入mysql的驱动和mybatis-plus的依赖
在数据层写接口 用mybatis-plus进行开发

业务层开发
先写接口

业务层的实现类

在测试类里面注入业务层接口
然后进行测试
然后用业务层接口调用方法

这边进行测试后
数据库数据会进行增加
我们要关闭事物 这样就不会对数据库进行操作

注解
@Transactional
这边做了一个数据回滚
Rollback
内部控制机制


测试用例设置随机用例
在配置文件设置

书写完成

写实体类进行封装

注入再执行

转码

随机生成的数据有范围控制

范围扩大

小结
