1.RunWith 注解

RunWith 就是一个运行器

可以在单元测试的时候,自动创建spring的应用上下文

2.正确使用

pom.xml


<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.ow2.asm</groupId>
<artifactId>asm</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-autoconfigure</artifactId>
</exclusion>
<exclusion>
<artifactId>log4j-api</artifactId>
<groupId>org.apache.logging.log4j</groupId>
</exclusion>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-to-slf4j</artifactId>
</exclusion>
</exclusions>
</dependency>

3.测试用例

@RunWith(SpringRunner.class)
@SpringBootTest
public class RdsTest { private static final Logger LOG = LoggerFactory.getLogger(RdsTest.class); @Resource
RdsClientHolder rdsClientHolder; @Resource
RdsInstanceTypesMapper rdsInstanceTypesMapper; /**
* 查询状态
*/
@Test
public void describeRds(){
RdsClient rdsClient = rdsClientHolder.getClientByPinAlias("tech_prod");
DescribeInstanceAttributesRequest request = new DescribeInstanceAttributesRequest();
request.setRegionId("cn-north-1");
request.setInstanceId("mysql-b706i2vpmt");
DescribeInstanceAttributesResponse describeResponse = rdsClient.describeInstanceAttributes(request);
LOG.info("describeResponse : {}",JsonUtils.toJSONString(describeResponse.getResult(), true));
}
}

最新文章

  1. .NET正则表达式基础入门(四)
  2. 微信小程序社区上线
  3. 一次 Oracle 算出运算溢出问题 排查解决 (并非除数为零!)
  4. AngularJS Best Practices: ng-include vs directive
  5. css左右居中的几种常见方法
  6. 10. 求N分之一序列前N项和
  7. HDOJ-ACM1097(JAVA) A hard puzzle
  8. iOS中保证线程安全的几种方式与性能对比
  9. border做箭头的例子
  10. 【Android 应用开发】对Android体系结构的理解--后续会补充
  11. H5、C3、ES6的新特性
  12. QPushButton class
  13. Pycharm问题:module &#39;pip&#39; has no attribute &#39;main&#39;
  14. javascript基础 之 void
  15. Vue小案例 之 商品管理------修改商品数量以及增加入库日期属性
  16. code vs 2639 约会计划
  17. 2018/03/11 每日一个Linux命令 之 top
  18. adb 安装软件
  19. 搭建 ssm 环境
  20. 多网卡绑定(bond)

热门文章

  1. 《机器学习Python实现_10_06_集成学习_boosting_gbdt分类实现》
  2. try catch 用法
  3. windows内核开发环境的简易搭建
  4. hdu 4309 最大流 + DFS
  5. 路由器逆向分析------MIPS系统网络的配置(QEMU)
  6. Python中Scapy网络嗅探模块的使用
  7. POJ1548最小路径覆盖
  8. nodejs-模块系统
  9. SQL注入平台第一关,注入?id=1&#39;不报错的问题
  10. OCR横向评测 -- 软工案例分析