如果想让junit和spring容器环境无缝对接的话,可以使用如下方式:

import com.jd.ptest.service.ICronService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import static org.junit.Assert.*; @RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"classpath:applicationContext.xml"}) //此处读取spring的配置文件
public class CronServiceImplTest { @Autowired
@SuppressWarnings("all")
ICronService cronService; @Test
public void addCron() {
try
{
cronService.addCron();
} catch (Exception e)
{
e.printStackTrace();
}
}
}

最新文章

  1. Yii框架CURD方法
  2. alias指令:设置命令别名
  3. Rigidbody相关的操作最好放在FixedUpdate中,update中可能会无效果
  4. axis
  5. onresize方法
  6. mfc学生成绩录入与查询
  7. MFC 构建、消亡 顺序 (一)--单文档 (SDI)
  8. WebService学习之四:关于JAX-WS 注释
  9. openwrt opkg update wget returned 4 wget returned 1
  10. java集合概念
  11. Css 之 px em %
  12. 阿里云oss总是提示SignatureDoesNotMatch错误怎么办
  13. Linux系统操作指令汇总
  14. php 使用composer
  15. HTML,js的基础知识
  16. Redhat 7 开通防火墙端口
  17. 【 js 工具 】如何使用Git上传本地项目到github?(mac版)
  18. google-gson 使用及GsonBuilder设置
  19. iOS绘图UIBezierPath 和 Core Graphics框架
  20. si4438 cca 侦听

热门文章

  1. 【Java并发核心九】并发集合框架
  2. SpringBoot学习历程
  3. 一道有意思的找规律题目 --- CodeForces - 964A
  4. BZOJ.4446.[SCOI2015]小凸玩密室(树形DP)
  5. BZOJ.4199.[NOI2015]品酒大会(后缀数组 单调栈)
  6. MySQL 一对多查询
  7. 2009 ACM 水题
  8. 【DWM1000】 code 解密3一ANCHOR RUN起来
  9. 潭州课堂25班:Ph201805201 django框架 第十一课 保持登录,注册,登录 (课堂笔记)
  10. Usaco 4.3.1 Buy Low, Buy Lower 逢低吸纳详细解题报告