- 需求分析 -> 设计 ->测试 -> 上线
单元测试: 完成最小的软件设计单元的验证工作, 目标是确保模板被正确的编码
- Spring Boot Test 是在Spring Test之上的再次封装吗使用@SpringBootTest后,Spring将加载所有被管理的bean,等同于启动了整个服务
common模块中添加依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
</dependency>
shop-user-service项目进行单元测试
@RunWith(SpringRunner.class)
@SpringBootTest(classes = UserApplication.class)
@Slf4j
public class AddressTest {
@Autowired
private AddressService addressService;
@Test
public void testAddressDetail() {
AddressDO addressDO = new AddressDO();
log.info(addressDO.toString());
}
}
- 单元测试结果
2025-08-06 09:42:22.655 INFO 14548 --- [ main] com.guslegend.test.AddressTest : AddressDO(id=null, userId=null, defaultStatus=null, receiveName=null, phone=null, province=null, city=null, region=null, detailAddress=null, createTime=null)


被折叠的 条评论
为什么被折叠?



