1.测试方法不能直接获取到系统初始化的配置信息,需要专门读取
2.单元测试多线程子线程不执行,不会像主线程一样等待子线程退出而退出, 会直接退出. 。
https://blog.csdn.net/yuechang5/article/details/79081697
springboot 测试service demo
@RunWith(SpringRunner.class) @SpringBootTest(classes = Application.class) public class UserRpcApiTest { @Reference(version = "1.0.0") private UserRpcApi userRpcApi; @Test public void testGetFullUserByUerName(){ ResultDTO<UserDTO> resultDTO = userRpcApi.getFullUserByUerName("admin"); if (resultDTO.isSuccess()) { System.out.println(resultDTO.getModule().toString()); } else { System.out.println("失败"); } }
@RunWith(SpringRunner.class)
@SpringBootTest(classes = Application.class)
这个必要,Application指的是项目启动类