0


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));
    }

}

本文转载自: https://blog.csdn.net/u013517141/article/details/130620897
版权归原作者 小莫分享 所有, 如有侵权,请联系我们删除。

“MybatisPlus 单元测试”的评论:

还没有评论