`
shiwj1010
  • 浏览: 97328 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

基础,每天记录一点点。junit最简单一个测试,测试业务方法

    博客分类:
  • j2se
阅读更多
最简单的一个测试,记录下,方便以后查询
import junit.framework.TestCase;

import org.springframework.context.support.AbstractApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import chuck.dao.StudentDAO;
import chuck.model.Student;

public class TestStudentDAOImpl extends TestCase {

	AbstractApplicationContext applicationContext = null;
	
	protected void setUp() throws Exception {
		applicationContext = new ClassPathXmlApplicationContext("applicationContext.xml");
	}

	protected void tearDown() throws Exception {

		applicationContext = null;
	}
	
	public void testInsertStudent2(){
		StudentDAO studentDAO = (StudentDAO) applicationContext
		.getBean("studentDAO");
		studentDAO.insertStudentV2(2,"zhangsan", "shanghai");
		Student student = studentDAO.getStudent(2);
		assertEquals(2, student.getId());
		assertEquals("zhangsan", student.getName());
		assertEquals("shanghai", student.getAddress());
	}

}
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics