aboutsummaryrefslogtreecommitdiff
path: root/app/src/androidTest
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/androidTest')
-rw-r--r--app/src/androidTest/kotlin/com/pitchedapps/frost/FrostTestApp.kt41
-rw-r--r--app/src/androidTest/kotlin/com/pitchedapps/frost/TestModules.kt19
2 files changed, 21 insertions, 39 deletions
diff --git a/app/src/androidTest/kotlin/com/pitchedapps/frost/FrostTestApp.kt b/app/src/androidTest/kotlin/com/pitchedapps/frost/FrostTestApp.kt
index 9d0caae6..2a834cc8 100644
--- a/app/src/androidTest/kotlin/com/pitchedapps/frost/FrostTestApp.kt
+++ b/app/src/androidTest/kotlin/com/pitchedapps/frost/FrostTestApp.kt
@@ -19,22 +19,13 @@ package com.pitchedapps.frost
import android.app.Application
import android.content.Context
import androidx.test.runner.AndroidJUnitRunner
-import ca.allanwang.kau.kpref.KPrefFactory
-import ca.allanwang.kau.kpref.KPrefFactoryInMemory
-import com.pitchedapps.frost.db.FrostDatabase
-import com.pitchedapps.frost.facebook.FbCookie
-import com.pitchedapps.frost.injectors.ThemeProvider
import com.pitchedapps.frost.prefs.Prefs
+import dagger.hilt.android.testing.HiltTestApplication
import org.junit.rules.TestRule
import org.junit.runner.Description
import org.junit.runners.model.Statement
-import org.koin.android.ext.koin.androidContext
-import org.koin.android.ext.koin.androidLogger
import org.koin.core.component.KoinComponent
import org.koin.core.component.get
-import org.koin.core.context.startKoin
-import org.koin.core.module.Module
-import org.koin.dsl.module
class FrostTestRunner : AndroidJUnitRunner() {
override fun newApplication(
@@ -42,7 +33,7 @@ class FrostTestRunner : AndroidJUnitRunner() {
className: String?,
context: Context?
): Application {
- return super.newApplication(cl, FrostTestApp::class.java.name, context)
+ return super.newApplication(cl, HiltTestApplication::class.java.name, context)
}
}
@@ -58,31 +49,3 @@ class FrostTestRule : TestRule {
}
}
}
-
-class FrostTestApp : Application() {
-
- override fun onCreate() {
- super.onCreate()
- startKoin {
- androidLogger()
- androidContext(this@FrostTestApp)
- modules(
- listOf(
- FrostDatabase.module(),
- prefFactoryModule(),
- Prefs.module(),
- FbCookie.module(),
- ThemeProvider.module()
- )
- )
- }
- }
-
- companion object {
- fun prefFactoryModule(): Module = module {
- single<KPrefFactory> {
- KPrefFactoryInMemory
- }
- }
- }
-}
diff --git a/app/src/androidTest/kotlin/com/pitchedapps/frost/TestModules.kt b/app/src/androidTest/kotlin/com/pitchedapps/frost/TestModules.kt
new file mode 100644
index 00000000..3d43f1b1
--- /dev/null
+++ b/app/src/androidTest/kotlin/com/pitchedapps/frost/TestModules.kt
@@ -0,0 +1,19 @@
+package com.pitchedapps.frost
+
+import ca.allanwang.kau.kpref.KPrefFactory
+import ca.allanwang.kau.kpref.KPrefFactoryInMemory
+import com.pitchedapps.frost.prefs.PrefFactoryModule
+import dagger.Module
+import dagger.Provides
+import dagger.hilt.components.SingletonComponent
+import dagger.hilt.testing.TestInstallIn
+
+@Module
+@TestInstallIn(
+ components = [SingletonComponent::class],
+ replaces = [PrefFactoryModule::class]
+)
+object PrefFactoryTestModule {
+ @Provides
+ fun factory(): KPrefFactory = KPrefFactoryInMemory
+}