首页 > 编程语言 > 详细

Spring 下使用Junit4 单元测试

时间:2019-04-29 00:54:31      阅读:132      评论:0      收藏:0      [点我收藏+]
package platform;


import java.util.List;
import java.util.UUID;

import javax.annotation.Resource;

import org.apache.commons.codec.digest.DigestUtils;
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 org.springframework.test.context.web.WebAppConfiguration;
import com.xxx.xxx.model.ProjectInfo;
import com.xxx.xxx.service.ProjectInfoService;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"classpath:applicationContext.xml"})
@WebAppConfiguration
public class JunitTest {
//    @Resource
    @Autowired
    private ProjectInfoService projectInfoService;

     @Test
     public void demo2(){
        ProjectInfo projectInfo = projectInfoService.findProjectInfoById("ID");
        System.out.println(projectInfo.getName());
     }
}

不写单元测试的程序员不是好程序员。

 

Spring 下使用Junit4 单元测试

原文:https://www.cnblogs.com/jkwll/p/10677015.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!