1

I'm trying to mock database access (OrmLiteSqliteOpenHelper).

I just need a piece of information or some example how to achieve that.

I tried to create OrmLiteSqliteOpenHelper with IsolatedContext, but after running the code, Android just uses the standard context.

Adam Lear
  • 38,111
  • 12
  • 81
  • 101
reizals
  • 1,245
  • 1
  • 14
  • 21

1 Answers1

3

If you check here you will see an answer for at least the latter part of your question: you need to extend InstrumentationTestCase rather than AndroidTestCase and call getInstrumentation().getContext() to get the context of the test application. However I have never used OrmLiteSqliteOpenHelper and do not know whether it will help to mock a database. Actually, I am also searching for a way to mock.

Community
  • 1
  • 1
Boris Strandjev
  • 46,145
  • 15
  • 108
  • 135