浏览 8638 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (1) :: 隐藏帖 (0)
|
|
---|---|
作者 | 正文 |
发表时间:2010-08-24
最后修改:2010-09-02
package com.javaeye.website.service; 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 com.javaeye.website.mg.service.CommentManager; //使用@RunWith(SpringJUnit4ClassRunner.class),才能使测试运行于Spring测试环境 @RunWith(SpringJUnit4ClassRunner.class) //@ContextConfiguration 注解有以下两个常用的属性: //locations:可以通过该属性手工指定 Spring 配置文件所在的位置,可以指定一个或多个 Spring 配置文件 //inheritLocations:是否要继承父测试类的 Spring 配置文件,默认为 true @ContextConfiguration(locations={"classpath:/spring/*-resource.xml", "classpath:/spring/*-validator.xml", "classpath:/spring/*-datasource.xml", "classpath:/spring/*-dao.xml", "classpath:/spring/*-service.xml"}) public class CommentManagerTest { @Autowired CommentManager manager; @Test public void indexTest() { //发表评论调用service业务方法 System.out.println(manager.addComment("comment_ID", "javaEyeComment", "61.129.70.27")); } } 声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
返回顶楼 | |