Testing Dynamic Datasource Order Retrieval in SpringBoot-Labs
This test suite validates the OrderMapper functionality in a dynamic datasource environment using ShardingJDBC. It demonstrates integration testing of database operations with Spring Boot, focusing on order data retrieval operations.
Test Coverage Overview
Implementation Analysis
Technical Details
Best Practices Demonstrated
yudaocode/springboot-labs
lab-17/lab-17-dynamic-datasource-sharding-jdbc-01/src/test/java/dynamicdatasource/mapper/OrderMapperTest.java
package dynamicdatasource.mapper;
import cn.iocoder.springboot.lab17.dynamicdatasource.Application;
import cn.iocoder.springboot.lab17.dynamicdatasource.dataobject.OrderDO;
import cn.iocoder.springboot.lab17.dynamicdatasource.mapper.OrderMapper;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
@SpringBootTest(classes = Application.class)
public class OrderMapperTest {
@Autowired
private OrderMapper orderMapper;
@Test
public void testSelectById() {
OrderDO order = orderMapper.selectById(1);
System.out.println(order);
}
}