---
title: "Spring JUnit4"
author: "JoeZe"
date: "2013-08-28T15:39:39Z"
tags: []
categories: ["企业架构"]
slug: "spring-junit4"
draft: false
lastmod: "2013-08-28T15:39:23Z"
id: 1932131
url: "https://joeze.iteye.com/blog/1932131"
---

使用Spring的测试框架需要加入以下依赖包：
JUnit 4,
Spring test包
Spring 相关其他依赖包

```java

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { 
		"classpath:applicationContext.xml",
		"classpath:com/test/spring-context-trans.xml" })

public class TransDaoTest {
	private static final Log log = LogFactory.getLog(TransDaoTest.class);

	@Autowired
	TransDao transDao;
	

	@Test
	public void test(){
		List<ConfLanguage> list= transDao.findLangsByCode("BOK");
		Assert.assertEquals(1,list.size());
	}
	
}

```