自動(dòng)導(dǎo)入 MyBatis-Plus 測(cè)試所需相關(guān)配置,通過(guò) ?@MybatisPlusTest
? 注解快速配置測(cè)試類。
Maven:
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter-test</artifactId>
<version>3.5.1</version>
</dependency>
Gradle:
compile group: 'com.baomidou', name: 'mybatis-plus-boot-starter-test', version: '3.5.1'
通過(guò) ?@MybatisPlusTest
? 可快速編寫(xiě) Mapper 對(duì)應(yīng)的測(cè)試類,實(shí)現(xiàn)快速測(cè)試代碼
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();
}
}
更多建議: