Skip to content Skip to sidebar Skip to footer

Cannot Instantiate Ormlite Helper In A Unit Test Class In Android Studio

This is my code: @RunWith(MockitoJUnitRunner.class) public class OrmLiteTest { OrmLiteDatabaseHelper databaseHelper; @Mock Context mMockContext; @Before publ

Solution 1:

You are trying to invoke a method (or similar) on an object which is null in the OrmLiteSqliteOpenHelper.java, line 310

As you didn't share that code, that's all we can say...

Caused by: java.lang.NullPointerException at com.j256.ormlite.android.apptools.OrmLiteSqliteOpenHelper.openFileId(OrmLiteSqliteOpenHelper.java:310)

Oh, and the line...

mMockContext = Mockito.mock(Context.class);

...should be removed, since the @RunWith(MockitoJUnitRunner.class) will already inject a mock there, no need to create one manually.

Post a Comment for "Cannot Instantiate Ormlite Helper In A Unit Test Class In Android Studio"