Hi hackbod,
Thanks for your reply and sorry for the delay in answering. Your
response makes perfect sense, but as you imagine I do not really want
to create implementations for all the mock methods. I would much
rather use a real context in my JUnit tests. You mentioned I sould get
a real context and use that. Do you know how I can pass or get a real
context to my JUnit class DbHelperTest?
public class DbHelperTest extends TestCase {
/**
* Set-up code for tests
*/
private MockContext context=new MockContext();
DbHelper mDbHelper=new DbHelper(context);
public void testCreateDatabase (){
//What other tests can I do? can I check the database is created?
try {
mDbHelper.open();
} catch (SQLException ex) {
fail(ex.getMessage());
}
//Database should have been created, proceed to check this is the
case
//but I can't check without calling the name...
}
}
Thanks so much!
Fernan.do