spring junit的一个问题

engourdi 2014-11-06 08:37:03
遇到一个很奇怪的问题,
我在测试用例里加上
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration("classpath:applicationContext.xml")

@test方法里就不执行

因为有以下引用,所以又必须去读取配置文件,但是
@Autowired
CommunityFacade cf;
所以还是必须在测试的时候读取spring的配置文件,求解啊!
他也不报错
[2014-11-06 20:34:34 678 INFO ] context.support.DefaultTestContextBootstrapper - Loaded default TestExecutionListener class names from location [META-INF/spring.factories]: [org.springframework.test.context.web.ServletTestExecutionListener, org.springframework.test.context.support.DependencyInjectionTestExecutionListener, org.springframework.test.context.support.DirtiesContextTestExecutionListener, org.springframework.test.context.transaction.TransactionalTestExecutionListener, org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener]
[2014-11-06 20:34:34 695 INFO ] context.support.DefaultTestContextBootstrapper - Using TestExecutionListeners: [org.springframework.test.context.web.ServletTestExecutionListener@7904f4c8, org.springframework.test.context.support.DependencyInjectionTestExecutionListener@3462b48a, org.springframework.test.context.support.DirtiesContextTestExecutionListener@3c3aeae4, org.springframework.test.context.transaction.TransactionalTestExecutionListener@40133da0, org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener@2f32f43d]
...全文
376 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
engourdi 2014-11-13
  • 打赏
  • 举报
回复
引用 6 楼 g29times 的回复:
我也遇到了这个问题 还没解决
我的问题解决了,原因,我的sring用的最新的4.X,后面我把junit升级到4.11然后重新用maven构建好久没问题了。
g29tony 2014-11-10
  • 打赏
  • 举报
回复
我也遇到了这个问题 还没解决
engourdi 2014-11-08
  • 打赏
  • 举报
回复
引用 4 楼 t_jl1979 的回复:
路径错了,应是: "classpath:/spring/applicationContext.xml"
没错啊,spring目录下只有rootcontext
attilax 2014-11-07
  • 打赏
  • 举报
回复
使用springUtil啊.
冥王之锤 2014-11-07
  • 打赏
  • 举报
回复
路径错了,应是: "classpath:/spring/applicationContext.xml"
engourdi 2014-11-07
  • 打赏
  • 举报
回复
就是这个配置文件是没有错的,但是我不知道怎么junit之前还好好的但是现在就只是打印出这两条信息,就不执行test方法。
[2014-11-06 20:34:34 678 INFO ] context.support.DefaultTestContextBootstrapper - Loaded default TestExecutionListener class names from location [META-INF/spring.factories]: [org.springframework.test.context.web.ServletTestExecutionListener, org.springframework.test.context.support.DependencyInjectionTestExecutionListener, org.springframework.test.context.support.DirtiesContextTestExecutionListener, org.springframework.test.context.transaction.TransactionalTestExecutionListener, org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener]
[2014-11-06 20:34:34 695 INFO ] context.support.DefaultTestContextBootstrapper - Using TestExecutionListeners: [org.springframework.test.context.web.ServletTestExecutionListener@7904f4c8, org.springframework.test.context.support.DependencyInjectionTestExecutionListener@3462b48a, org.springframework.test.context.support.DirtiesContextTestExecutionListener@3c3aeae4, org.springframework.test.context.transaction.TransactionalTestExecutionListener@40133da0, org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener@2f32f43d]
百里马 2014-11-07
  • 打赏
  • 举报
回复
我是专门复制了一个配置文件专门供jUnit来runwith 比较方便吧,可以达到目的就没有去找别的方法了~

67,513

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧