Skip to content

Unit Testing

It will automatically import the configurations required for MyBatis-Plus testing. You can quickly configure test classes using the @MybatisPlusTest annotation.

Sample Project

Usage Guide

  1. Add Test Dependency

    <dependency>
    <groupId>com.baomidou</groupId>
    <artifactId>mybatis-plus-boot-starter-test</artifactId>
    <version>3.5.12</version>
    </dependency>
  2. Write Test Cases

    import org.junit.jupiter.api.Test;
    import org.springframework.beans.factory.annotation.Autowired;
    import static org.assertj.core.api.Assertions.assertThat;
    @MybatisPlusTest
    class MybatisPlusSampleTest {
    @Autowired
    private SampleMapper sampleMapper;
    @Test
    void testInsert() {
    Sample sample = new Sample();
    sampleMapper.insert(sample);
    assertThat(sample.getId()).isNotNull();
    }
    }
Baomidou

© 2016-2025 Baomidou™. All Rights Reserved.

Power by Astro Starlight | Sponsored by JetBrains

渝ICP备2021000141号-1 | 渝公网安备50011302222097