Skip to content

Instantly share code, notes, and snippets.

@ggdio
Created September 30, 2013 16:08
Show Gist options
  • Save ggdio/6766122 to your computer and use it in GitHub Desktop.
Save ggdio/6766122 to your computer and use it in GitHub Desktop.
Integration TEST for DAOs and SQLs - JUnit
//Imports
public class DaoTestExample {
//The class fields to be used
private Session session;
private MyDao dao;
//Before each test
@Before
public void before(){
//Here you must create your session connection and daos
session = new MySessionFactory().createSession();
dao = new MyDao(session);
}
//After each test
@After
public void after(){
session.getTransaction().rollback();
session.close();
}
@Test
public void someTest(){
//Here you use your dao
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment