单元测试
自动导入 MyBatis-Plus 测试所需相关配置,通过 @MybatisPlusTest
注解快速配置测试类。
示例工程
mybatis-plus-boot-starter-test MyBatis-Plus 快速测试功能相关源码
使用教程
-
添加测试依赖
-
编写测试用例
import org.junit.jupiter.api.Test;import org.springframework.beans.factory.annotation.Autowired;import static org.assertj.core.api.Assertions.assertThat;@MybatisPlusTestclass MybatisPlusSampleTest {@Autowiredprivate SampleMapper sampleMapper;@Testvoid testInsert() {Sample sample = new Sample();sampleMapper.insert(sample);assertThat(sample.getId()).isNotNull();}}