Spring 下使用Junit4 单元测试
生活随笔
收集整理的這篇文章主要介紹了
Spring 下使用Junit4 单元测试
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
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 单元测试的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 大一新生第一天干什么(要做的事情有哪些)
- 下一篇: Test注解的两个属性(转)