Unit Testing
Automatically imports the required configurations for MyBatis-Plus testing. Quickly configure test classes using the @MybatisPlusTest annotation.
Example Project
mybatis-plus-boot-starter-test Source code related to MyBatis-Plus quick testing functionality
Usage Tutorial
-
Add test dependency
-
Write test cases
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();}}import org.junit.jupiter.api.Testimport org.springframework.beans.factory.annotation.Autowiredimport org.assertj.core.api.Assertions.assertThat@MybatisPlusTestclass MybatisPlusSampleTest {@Autowiredlateinit var sampleMapper: SampleMapper@Testfun testInsert() {val sample = Sample()sampleMapper.insert(sample)assertThat(sample.id).isNotNull()}}