您现在的位置是:首页 >技术交流 >MybatisPlus 单元测试网站首页技术交流
MybatisPlus 单元测试
简介MybatisPlus 单元测试
@RunWith(SpringRunner.class)
@ActiveProfiles(profiles = "local")
@AutoConfigureCache
@AutoConfigureMybatisPlus
@AutoConfigureTestDatabase(replace = AutoConfigureTestDatabase.Replace.NONE)
public abstract class BaseMockTest {
@BeforeClass
public static void setUp() throws Exception {
//日志输出
System.getProperties().put("spring.profiles.active", "local");
}
}
@MybatisPlusTest
@Rollback
@Import(MesaMybatisAutoConfigure.class)
@AutoConfigureTestDatabase(replace = AutoConfigureTestDatabase.Replace.NONE)
public abstract class BaseMockMapperTest extends BaseMockTest {
}
单元测试样例
public class MockAfterTest extends BaseMockMapperTest { @Resource private MerchantOrderSubMapper merchantOrderSubMapper; @Resource private MerchantOrderSubItemMapper merchantOrderSubItemMapper; @Resource private TMerchantOrderAfterMapper merchantOrderAfterMapper; @Test public void mockAfterOrder() { String orderNo = "123"; MerchantOrderSub orderEntity = merchantOrderSubMapper.findOneByOrderNo(orderNo); List<MerchantOrderSubItem> orderItemList = merchantOrderSubItemMapper.loadItemList(Lists.newArrayList(orderNo)); System.out.println(JSON.toJSONString(orderEntity)); System.out.println(JSON.toJSONString(orderItemList)); } }
风语者!平时喜欢研究各种技术,目前在从事后端开发工作,热爱生活、热爱工作。