Last active
April 6, 2022 02:15
-
-
Save A-pZ/a4ba69f3212cbbec7b014bfb0847d8d4 to your computer and use it in GitHub Desktop.
ItemMapperDBUnitTest
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.github.apz.sample.mapper; | |
import static org.junit.Assert.*; | |
import org.junit.jupiter.api.Test; | |
import org.mybatis.spring.boot.test.autoconfigure.MybatisTest; | |
import org.springframework.beans.factory.annotation.Autowired; | |
import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; | |
import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase.Replace; | |
import org.springframework.test.context.TestExecutionListeners; | |
import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; | |
import org.springframework.test.context.support.DirtiesContextTestExecutionListener; | |
import com.github.springtestdbunit.DbUnitTestExecutionListener; | |
import com.github.springtestdbunit.TransactionDbUnitTestExecutionListener; | |
import com.github.springtestdbunit.annotation.DatabaseOperation; | |
import com.github.springtestdbunit.annotation.DatabaseSetup; | |
import com.github.springtestdbunit.annotation.DbUnitConfiguration; | |
@MybatisTest | |
@AutoConfigureTestDatabase(replace = Replace.NONE) | |
@TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, DirtiesContextTestExecutionListener.class, TransactionDbUnitTestExecutionListener.class, DbUnitTestExecutionListener.class }) | |
@DbUnitConfiguration(dataSetLoader = CSVDataSetLoader.class, databaseConnection = { "dbUnitDatabaseConnection" }) | |
public class ItemMapperDBUnitTest { | |
@Autowired | |
ItemMapper mapper; | |
@Test | |
@DatabaseSetup(connection = "dbUnitDatabaseConnection", value = "/", type = DatabaseOperation.CLEAN_INSERT) | |
public void 検索() { | |
var items = mapper.findById("6"); | |
assertTrue(!items.isEmpty()); | |
assertTrue(items.size() == 1); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment