mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-05-19 12:18:59 +00:00
use mock realm in tests
This commit is contained in:
parent
fb18520da6
commit
dbfa12c830
5 changed files with 43 additions and 4 deletions
|
|
@ -126,9 +126,9 @@ dependencies {
|
|||
testCompile "junit:junit:4.10"
|
||||
testCompile "org.assertj:assertj-core:1.7.0"
|
||||
testCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5'
|
||||
testCompile "org.robolectric:robolectric:3.2"
|
||||
testCompile 'org.robolectric:shadows-multidex:3.1'
|
||||
testCompile "org.robolectric:shadows-support-v4:3.1"
|
||||
testCompile "org.robolectric:robolectric:3.3.2"
|
||||
testCompile 'org.robolectric:shadows-multidex:3.3.2'
|
||||
testCompile "org.robolectric:shadows-support-v4:3.3.2"
|
||||
testCompile "org.mockito:mockito-core:1.10.19"
|
||||
|
||||
//Leak Detection
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ public class RepositoryModule {
|
|||
}
|
||||
|
||||
@Provides
|
||||
Realm providesRealm() {
|
||||
public Realm providesRealm() {
|
||||
return Realm.getDefaultInstance();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,20 @@
|
|||
package com.habitrpg.android.habitica;
|
||||
|
||||
import com.habitrpg.android.habitica.components.AppComponent;
|
||||
import com.habitrpg.android.habitica.components.DaggerAppComponent;
|
||||
import com.habitrpg.android.habitica.modules.AppModule;
|
||||
|
||||
public class TestApplication extends HabiticaBaseApplication {
|
||||
@Override
|
||||
protected AppComponent initDagger() {
|
||||
return DaggerAppComponent.builder()
|
||||
.appModule(new AppModule(this))
|
||||
.developerModule(new DebugDeveloperModule())
|
||||
.repositoryModule(new TestRepositoryModule())
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setupRealm() {
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
package com.habitrpg.android.habitica;
|
||||
|
||||
import com.habitrpg.android.habitica.modules.RepositoryModule;
|
||||
|
||||
import org.mockito.Mockito;
|
||||
|
||||
import dagger.Provides;
|
||||
import io.realm.Realm;
|
||||
|
||||
class TestRepositoryModule extends RepositoryModule {
|
||||
|
||||
|
||||
@Provides
|
||||
@Override
|
||||
public Realm providesRealm() {
|
||||
return Mockito.mock(Realm.class);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,3 +1,4 @@
|
|||
sdk=21
|
||||
packageName=com.habitrpg.android.habitica
|
||||
manifest=AndroidManifest.xml
|
||||
application=comh.habitrpg.android.habitica.TestApplication
|
||||
Loading…
Reference in a new issue