ユニットテスト
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();}}