Skip to content

Unit Testing

Automatically imports the required configurations for MyBatis-Plus testing, quickly configuring test classes through the @MybatisPlusTest annotation.

Example Project

Usage Tutorial

  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 case

    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