Created
September 30, 2013 16:08
-
-
Save ggdio/6766122 to your computer and use it in GitHub Desktop.
Integration TEST for DAOs and SQLs - JUnit
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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