Easy reference for beginners
import java.util.List; import junit.framework.TestCase; import junit.framework.TestSuite; import org.springframework.beans.factory.xml.XMLBeanFactory; import org.springframework.core.io.ClassPathResource; import dataAccess.ContactMeDao; import dto.AdmetDTO; public class ContactMeDaoTest extends TestCase { ContactMeDao contactMeDao = null; public ContactMeDaoTest(String arg) { super(arg); XMLBeanFactory beanFactory = new XMLBeanFactory(new ClassPathResource(resource/ApplicationContext.xml); contactMeDao = (ContactMeDao )beanFactory .getBean("contactMeDao"); } public static TestSuite suite() { TestSuite suite = new TestSuite(); suite.addTest(new ContactMeDaoTest ("testPrintMe)); return suite; } //AdmetDTO is DTO class in which data is returned from DB layer. //We are Unit testing printMe function of lass named ContactMeDao public void printMe() { List<AdmetDTO> list = contactMeDao.printMe(); assertNotNull(list); } }