diff --git a/app-shared-test/.gitignore b/app-shared-test/.gitignore
new file mode 100644
index 0000000..42afabf
--- /dev/null
+++ b/app-shared-test/.gitignore
@@ -0,0 +1 @@
+/build
\ No newline at end of file
diff --git a/app-shared-test/build.gradle b/app-shared-test/build.gradle
new file mode 100644
index 0000000..c9a64d4
--- /dev/null
+++ b/app-shared-test/build.gradle
@@ -0,0 +1,46 @@
+plugins {
+ id 'com.android.library'
+ id 'org.jetbrains.kotlin.android'
+}
+
+android {
+ compileSdk 31
+
+ defaultConfig {
+ minSdk 21
+ targetSdk 31
+
+ testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
+ consumerProguardFiles "consumer-rules.pro"
+ }
+
+ buildTypes {
+ release {
+ minifyEnabled false
+ proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
+ }
+ }
+ sourceSets {
+ main {
+ assets.srcDirs += files("$projectDir/../app/schemas".toString())
+ resources.srcDirs += files("$projectDir/../app/schemas".toString())
+ }
+ }
+ compileOptions {
+ sourceCompatibility JavaVersion.VERSION_1_8
+ targetCompatibility JavaVersion.VERSION_1_8
+ }
+ kotlinOptions {
+ jvmTarget = '1.8'
+ }
+}
+
+dependencies {
+ implementation project(":app")
+ implementation project(':test-util-android')
+ implementation testFixtures(project(':core'))
+ implementation "io.insert-koin:koin-android:$koin_version"
+ implementation project(':test-util-shared-robolectric')
+
+ applyAppSharedTestDependenciesTo(this)
+}
\ No newline at end of file
diff --git a/app-shared-test/consumer-rules.pro b/app-shared-test/consumer-rules.pro
new file mode 100644
index 0000000..e69de29
diff --git a/app-shared-test/proguard-rules.pro b/app-shared-test/proguard-rules.pro
new file mode 100644
index 0000000..481bb43
--- /dev/null
+++ b/app-shared-test/proguard-rules.pro
@@ -0,0 +1,21 @@
+# Add project specific ProGuard rules here.
+# You can control the set of applied configuration files using the
+# proguardFiles setting in build.gradle.
+#
+# For more details, see
+# http://developer.android.com/guide/developing/tools/proguard.html
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+# public *;
+#}
+
+# Uncomment this to preserve the line number information for
+# debugging stack traces.
+#-keepattributes SourceFile,LineNumberTable
+
+# If you keep the line number information, uncomment this to
+# hide the original source file name.
+#-renamesourcefileattribute SourceFile
\ No newline at end of file
diff --git a/app-shared-test/src/main/AndroidManifest.xml b/app-shared-test/src/main/AndroidManifest.xml
new file mode 100644
index 0000000..617ac35
--- /dev/null
+++ b/app-shared-test/src/main/AndroidManifest.xml
@@ -0,0 +1,5 @@
+
+
+
+
\ No newline at end of file
diff --git a/app/src/sharedTest/java/org/fnives/test/showcase/storage/migration/MigrationToLatestInstrumentedTest.kt b/app-shared-test/src/main/java/org/fnives/test/showcase/storage/migration/MigrationToLatestInstrumentedSharedTest.kt
similarity index 97%
rename from app/src/sharedTest/java/org/fnives/test/showcase/storage/migration/MigrationToLatestInstrumentedTest.kt
rename to app-shared-test/src/main/java/org/fnives/test/showcase/storage/migration/MigrationToLatestInstrumentedSharedTest.kt
index a2527aa..4061051 100644
--- a/app/src/sharedTest/java/org/fnives/test/showcase/storage/migration/MigrationToLatestInstrumentedTest.kt
+++ b/app-shared-test/src/main/java/org/fnives/test/showcase/storage/migration/MigrationToLatestInstrumentedSharedTest.kt
@@ -23,7 +23,7 @@ import java.io.IOException
* https://developer.android.com/training/data-storage/room/migrating-db-versions
*/
@RunWith(AndroidJUnit4::class)
-class MigrationToLatestInstrumentedTest {
+open class MigrationToLatestInstrumentedSharedTest {
@get:Rule
val helper = SharedMigrationTestRule(instrumentation = InstrumentationRegistry.getInstrumentation())
@@ -48,7 +48,7 @@ class MigrationToLatestInstrumentedTest {
@Test
@Throws(IOException::class)
- fun migrate1To2() {
+ open fun migrate1To2() {
val expectedEntities = setOf(
FavouriteEntity("123"),
FavouriteEntity("124"),
diff --git a/app/src/sharedTest/java/org/fnives/test/showcase/testutils/MockServerScenarioSetupResetingTestRule.kt b/app-shared-test/src/main/java/org/fnives/test/showcase/testutils/MockServerScenarioSetupResetingTestRule.kt
similarity index 100%
rename from app/src/sharedTest/java/org/fnives/test/showcase/testutils/MockServerScenarioSetupResetingTestRule.kt
rename to app-shared-test/src/main/java/org/fnives/test/showcase/testutils/MockServerScenarioSetupResetingTestRule.kt
diff --git a/app/src/sharedTest/java/org/fnives/test/showcase/testutils/ReloadKoinModulesIfNecessaryTestRule.kt b/app-shared-test/src/main/java/org/fnives/test/showcase/testutils/ReloadKoinModulesIfNecessaryTestRule.kt
similarity index 100%
rename from app/src/sharedTest/java/org/fnives/test/showcase/testutils/ReloadKoinModulesIfNecessaryTestRule.kt
rename to app-shared-test/src/main/java/org/fnives/test/showcase/testutils/ReloadKoinModulesIfNecessaryTestRule.kt
diff --git a/app/src/sharedTest/java/org/fnives/test/showcase/testutils/idling/AsyncDiffUtilInstantTestRule.kt b/app-shared-test/src/main/java/org/fnives/test/showcase/testutils/idling/AsyncDiffUtilInstantTestRule.kt
similarity index 100%
rename from app/src/sharedTest/java/org/fnives/test/showcase/testutils/idling/AsyncDiffUtilInstantTestRule.kt
rename to app-shared-test/src/main/java/org/fnives/test/showcase/testutils/idling/AsyncDiffUtilInstantTestRule.kt
diff --git a/app/src/sharedTest/java/org/fnives/test/showcase/testutils/idling/DatabaseDispatcherTestRule.kt b/app-shared-test/src/main/java/org/fnives/test/showcase/testutils/idling/DatabaseDispatcherTestRule.kt
similarity index 100%
rename from app/src/sharedTest/java/org/fnives/test/showcase/testutils/idling/DatabaseDispatcherTestRule.kt
rename to app-shared-test/src/main/java/org/fnives/test/showcase/testutils/idling/DatabaseDispatcherTestRule.kt
diff --git a/app/src/sharedTest/java/org/fnives/test/showcase/testutils/idling/MainDispatcherTestRule.kt b/app-shared-test/src/main/java/org/fnives/test/showcase/testutils/idling/MainDispatcherTestRule.kt
similarity index 100%
rename from app/src/sharedTest/java/org/fnives/test/showcase/testutils/idling/MainDispatcherTestRule.kt
rename to app-shared-test/src/main/java/org/fnives/test/showcase/testutils/idling/MainDispatcherTestRule.kt
diff --git a/app/src/sharedTest/java/org/fnives/test/showcase/testutils/idling/NetworkSynchronizationTestRule.kt b/app-shared-test/src/main/java/org/fnives/test/showcase/testutils/idling/NetworkSynchronizationTestRule.kt
similarity index 100%
rename from app/src/sharedTest/java/org/fnives/test/showcase/testutils/idling/NetworkSynchronizationTestRule.kt
rename to app-shared-test/src/main/java/org/fnives/test/showcase/testutils/idling/NetworkSynchronizationTestRule.kt
diff --git a/app/src/sharedTest/java/org/fnives/test/showcase/testutils/statesetup/SetupAuthenticationState.kt b/app-shared-test/src/main/java/org/fnives/test/showcase/testutils/statesetup/SetupAuthenticationState.kt
similarity index 100%
rename from app/src/sharedTest/java/org/fnives/test/showcase/testutils/statesetup/SetupAuthenticationState.kt
rename to app-shared-test/src/main/java/org/fnives/test/showcase/testutils/statesetup/SetupAuthenticationState.kt
diff --git a/app/src/sharedTest/java/org/fnives/test/showcase/testutils/storage/TestDatabaseInitialization.kt b/app-shared-test/src/main/java/org/fnives/test/showcase/testutils/storage/TestDatabaseInitialization.kt
similarity index 100%
rename from app/src/sharedTest/java/org/fnives/test/showcase/testutils/storage/TestDatabaseInitialization.kt
rename to app-shared-test/src/main/java/org/fnives/test/showcase/testutils/storage/TestDatabaseInitialization.kt
diff --git a/app/src/sharedTest/java/org/fnives/test/showcase/ui/home/HomeRobot.kt b/app-shared-test/src/main/java/org/fnives/test/showcase/ui/home/HomeRobot.kt
similarity index 100%
rename from app/src/sharedTest/java/org/fnives/test/showcase/ui/home/HomeRobot.kt
rename to app-shared-test/src/main/java/org/fnives/test/showcase/ui/home/HomeRobot.kt
diff --git a/app/src/sharedTest/java/org/fnives/test/showcase/ui/home/MainActivityInstrumentedTest.kt b/app-shared-test/src/main/java/org/fnives/test/showcase/ui/home/MainActivityInstrumentedSharedTest.kt
similarity index 99%
rename from app/src/sharedTest/java/org/fnives/test/showcase/ui/home/MainActivityInstrumentedTest.kt
rename to app-shared-test/src/main/java/org/fnives/test/showcase/ui/home/MainActivityInstrumentedSharedTest.kt
index 7b4af06..1678675 100644
--- a/app/src/sharedTest/java/org/fnives/test/showcase/ui/home/MainActivityInstrumentedTest.kt
+++ b/app-shared-test/src/main/java/org/fnives/test/showcase/ui/home/MainActivityInstrumentedSharedTest.kt
@@ -26,7 +26,7 @@ import org.koin.test.KoinTest
@Suppress("TestFunctionName")
@RunWith(AndroidJUnit4::class)
-class MainActivityInstrumentedTest : KoinTest {
+open class MainActivityInstrumentedSharedTest : KoinTest {
private lateinit var activityScenario: ActivityScenario
diff --git a/app/src/sharedTest/java/org/fnives/test/showcase/ui/login/AuthActivityInstrumentedTest.kt b/app-shared-test/src/main/java/org/fnives/test/showcase/ui/login/AuthActivityInstrumentedSharedTest.kt
similarity index 98%
rename from app/src/sharedTest/java/org/fnives/test/showcase/ui/login/AuthActivityInstrumentedTest.kt
rename to app-shared-test/src/main/java/org/fnives/test/showcase/ui/login/AuthActivityInstrumentedSharedTest.kt
index 7d7159d..d838949 100644
--- a/app/src/sharedTest/java/org/fnives/test/showcase/ui/login/AuthActivityInstrumentedTest.kt
+++ b/app-shared-test/src/main/java/org/fnives/test/showcase/ui/login/AuthActivityInstrumentedSharedTest.kt
@@ -21,7 +21,7 @@ import org.koin.test.KoinTest
@Suppress("TestFunctionName")
@RunWith(AndroidJUnit4::class)
-class AuthActivityInstrumentedTest : KoinTest {
+open class AuthActivityInstrumentedSharedTest : KoinTest {
private lateinit var activityScenario: ActivityScenario
diff --git a/app/src/sharedTest/java/org/fnives/test/showcase/ui/login/LoginRobot.kt b/app-shared-test/src/main/java/org/fnives/test/showcase/ui/login/LoginRobot.kt
similarity index 100%
rename from app/src/sharedTest/java/org/fnives/test/showcase/ui/login/LoginRobot.kt
rename to app-shared-test/src/main/java/org/fnives/test/showcase/ui/login/LoginRobot.kt
diff --git a/app/src/sharedTest/java/org/fnives/test/showcase/ui/splash/SplashActivityInstrumentedTest.kt b/app-shared-test/src/main/java/org/fnives/test/showcase/ui/splash/SplashActivityInstrumentedSharedTest.kt
similarity index 95%
rename from app/src/sharedTest/java/org/fnives/test/showcase/ui/splash/SplashActivityInstrumentedTest.kt
rename to app-shared-test/src/main/java/org/fnives/test/showcase/ui/splash/SplashActivityInstrumentedSharedTest.kt
index 9c72866..f08761a 100644
--- a/app/src/sharedTest/java/org/fnives/test/showcase/ui/splash/SplashActivityInstrumentedTest.kt
+++ b/app-shared-test/src/main/java/org/fnives/test/showcase/ui/splash/SplashActivityInstrumentedSharedTest.kt
@@ -3,7 +3,6 @@ package org.fnives.test.showcase.ui.splash
import androidx.lifecycle.Lifecycle
import androidx.test.core.app.ActivityScenario
import androidx.test.espresso.intent.Intents
-import androidx.test.ext.junit.runners.AndroidJUnit4
import org.fnives.test.showcase.android.testutil.activity.SafeCloseActivityRule
import org.fnives.test.showcase.android.testutil.intent.DismissSystemDialogsRule
import org.fnives.test.showcase.android.testutil.screenshot.ScreenshotRule
@@ -16,12 +15,10 @@ import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.junit.rules.RuleChain
-import org.junit.runner.RunWith
import org.koin.test.KoinTest
@Suppress("TestFunctionName")
-@RunWith(AndroidJUnit4::class)
-class SplashActivityInstrumentedTest : KoinTest {
+open class SplashActivityInstrumentedSharedTest : KoinTest {
private lateinit var activityScenario: ActivityScenario
diff --git a/app/src/sharedTest/java/org/fnives/test/showcase/ui/splash/SplashRobot.kt b/app-shared-test/src/main/java/org/fnives/test/showcase/ui/splash/SplashRobot.kt
similarity index 100%
rename from app/src/sharedTest/java/org/fnives/test/showcase/ui/splash/SplashRobot.kt
rename to app-shared-test/src/main/java/org/fnives/test/showcase/ui/splash/SplashRobot.kt
diff --git a/app/build.gradle b/app/build.gradle
index 7d3b0e4..7234e88 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -42,13 +42,11 @@ android {
sourceSets {
androidTest {
- java.srcDirs += "src/sharedTest/java"
- assets.srcDirs += files("$projectDir/schemas".toString())
+// assets.srcDirs += files("$projectDir/schemas".toString())
}
test {
- java.srcDirs += "src/sharedTest/java"
java.srcDirs += "src/robolectricTest/java"
- resources.srcDirs += files("$projectDir/schemas".toString())
+// resources.srcDirs += files("$projectDir/schemas".toString())
}
}
@@ -115,6 +113,9 @@ dependencies {
testImplementation testFixtures(project(':core'))
androidTestImplementation testFixtures(project(':core'))
+ testImplementation project(':app-shared-test')
+ androidTestImplementation project(':app-shared-test')
+
// case specific
implementation project(":examplecase:example-navcontroller")
}
diff --git a/app/src/androidTest/java/org/fnives/test/showcase/storage/migration/MigrationToLatestInstrumentedTest.kt b/app/src/androidTest/java/org/fnives/test/showcase/storage/migration/MigrationToLatestInstrumentedTest.kt
new file mode 100644
index 0000000..e59caf7
--- /dev/null
+++ b/app/src/androidTest/java/org/fnives/test/showcase/storage/migration/MigrationToLatestInstrumentedTest.kt
@@ -0,0 +1,7 @@
+package org.fnives.test.showcase.storage.migration
+
+import androidx.test.ext.junit.runners.AndroidJUnit4
+import org.junit.runner.RunWith
+
+@RunWith(AndroidJUnit4::class)
+class MigrationToLatestInstrumentedTest : MigrationToLatestInstrumentedSharedTest()
diff --git a/app/src/androidTest/java/org/fnives/test/showcase/ui/home/MainActivityInstrumentedTest.kt b/app/src/androidTest/java/org/fnives/test/showcase/ui/home/MainActivityInstrumentedTest.kt
new file mode 100644
index 0000000..c348e32
--- /dev/null
+++ b/app/src/androidTest/java/org/fnives/test/showcase/ui/home/MainActivityInstrumentedTest.kt
@@ -0,0 +1,7 @@
+package org.fnives.test.showcase.ui.home
+
+import androidx.test.ext.junit.runners.AndroidJUnit4
+import org.junit.runner.RunWith
+
+@RunWith(AndroidJUnit4::class)
+class MainActivityInstrumentedTest : MainActivityInstrumentedSharedTest()
diff --git a/app/src/androidTest/java/org/fnives/test/showcase/ui/login/AuthActivityInstrumentedTest.kt b/app/src/androidTest/java/org/fnives/test/showcase/ui/login/AuthActivityInstrumentedTest.kt
new file mode 100644
index 0000000..78b6753
--- /dev/null
+++ b/app/src/androidTest/java/org/fnives/test/showcase/ui/login/AuthActivityInstrumentedTest.kt
@@ -0,0 +1,7 @@
+package org.fnives.test.showcase.ui.login
+
+import androidx.test.ext.junit.runners.AndroidJUnit4
+import org.junit.runner.RunWith
+
+@RunWith(AndroidJUnit4::class)
+class AuthActivityInstrumentedTest : AuthActivityInstrumentedSharedTest()
diff --git a/app/src/androidTest/java/org/fnives/test/showcase/ui/splash/SplashActivityInstrumentedTest.kt b/app/src/androidTest/java/org/fnives/test/showcase/ui/splash/SplashActivityInstrumentedTest.kt
new file mode 100644
index 0000000..2d44cf1
--- /dev/null
+++ b/app/src/androidTest/java/org/fnives/test/showcase/ui/splash/SplashActivityInstrumentedTest.kt
@@ -0,0 +1,7 @@
+package org.fnives.test.showcase.ui.splash
+
+import androidx.test.ext.junit.runners.AndroidJUnit4
+import org.junit.runner.RunWith
+
+@RunWith(AndroidJUnit4::class)
+class SplashActivityInstrumentedTest : SplashActivityInstrumentedSharedTest()
diff --git a/app/src/robolectricTest/java/org/fnives/test/showcase/storage/migration/MigrationToLatestInstrumentedTest.kt b/app/src/robolectricTest/java/org/fnives/test/showcase/storage/migration/MigrationToLatestInstrumentedTest.kt
new file mode 100644
index 0000000..e59caf7
--- /dev/null
+++ b/app/src/robolectricTest/java/org/fnives/test/showcase/storage/migration/MigrationToLatestInstrumentedTest.kt
@@ -0,0 +1,7 @@
+package org.fnives.test.showcase.storage.migration
+
+import androidx.test.ext.junit.runners.AndroidJUnit4
+import org.junit.runner.RunWith
+
+@RunWith(AndroidJUnit4::class)
+class MigrationToLatestInstrumentedTest : MigrationToLatestInstrumentedSharedTest()
diff --git a/app/src/robolectricTest/java/org/fnives/test/showcase/ui/home/MainActivityInstrumentedTest.kt b/app/src/robolectricTest/java/org/fnives/test/showcase/ui/home/MainActivityInstrumentedTest.kt
new file mode 100644
index 0000000..c348e32
--- /dev/null
+++ b/app/src/robolectricTest/java/org/fnives/test/showcase/ui/home/MainActivityInstrumentedTest.kt
@@ -0,0 +1,7 @@
+package org.fnives.test.showcase.ui.home
+
+import androidx.test.ext.junit.runners.AndroidJUnit4
+import org.junit.runner.RunWith
+
+@RunWith(AndroidJUnit4::class)
+class MainActivityInstrumentedTest : MainActivityInstrumentedSharedTest()
diff --git a/app/src/robolectricTest/java/org/fnives/test/showcase/ui/login/AuthActivityInstrumentedTest.kt b/app/src/robolectricTest/java/org/fnives/test/showcase/ui/login/AuthActivityInstrumentedTest.kt
new file mode 100644
index 0000000..78b6753
--- /dev/null
+++ b/app/src/robolectricTest/java/org/fnives/test/showcase/ui/login/AuthActivityInstrumentedTest.kt
@@ -0,0 +1,7 @@
+package org.fnives.test.showcase.ui.login
+
+import androidx.test.ext.junit.runners.AndroidJUnit4
+import org.junit.runner.RunWith
+
+@RunWith(AndroidJUnit4::class)
+class AuthActivityInstrumentedTest : AuthActivityInstrumentedSharedTest()
diff --git a/app/src/robolectricTest/java/org/fnives/test/showcase/ui/splash/SplashActivityInstrumentedTest.kt b/app/src/robolectricTest/java/org/fnives/test/showcase/ui/splash/SplashActivityInstrumentedTest.kt
new file mode 100644
index 0000000..2d44cf1
--- /dev/null
+++ b/app/src/robolectricTest/java/org/fnives/test/showcase/ui/splash/SplashActivityInstrumentedTest.kt
@@ -0,0 +1,7 @@
+package org.fnives.test.showcase.ui.splash
+
+import androidx.test.ext.junit.runners.AndroidJUnit4
+import org.junit.runner.RunWith
+
+@RunWith(AndroidJUnit4::class)
+class SplashActivityInstrumentedTest : SplashActivityInstrumentedSharedTest()
diff --git a/app/src/sharedTest/java/org/fnives/test/showcase/ui/login/codekata/CodeKataAuthActivitySharedTest.kt b/app/src/sharedTest/java/org/fnives/test/showcase/ui/login/codekata/CodeKataAuthActivitySharedTest.kt
deleted file mode 100644
index 30de5cf..0000000
--- a/app/src/sharedTest/java/org/fnives/test/showcase/ui/login/codekata/CodeKataAuthActivitySharedTest.kt
+++ /dev/null
@@ -1,51 +0,0 @@
-package org.fnives.test.showcase.ui.login.codekata
-
-import androidx.test.ext.junit.runners.AndroidJUnit4
-import kotlinx.coroutines.ExperimentalCoroutinesApi
-import org.junit.After
-import org.junit.Before
-import org.junit.Ignore
-import org.junit.Test
-import org.junit.runner.RunWith
-import org.koin.core.context.GlobalContext
-import org.koin.test.KoinTest
-
-@RunWith(AndroidJUnit4::class)
-@OptIn(ExperimentalCoroutinesApi::class)
-@Ignore("CodeKata")
-class CodeKataAuthActivitySharedTest : KoinTest {
-
- @Before
- fun setup() {
- }
-
- @After
- fun tearDown() {
- GlobalContext.stopKoin()
- }
-
- /** GIVEN non empty password and username and successful response WHEN signIn THEN no error is shown and navigating to home */
- @Test
- fun properLoginResultsInNavigationToHome() {
- }
-
- /** GIVEN empty password and username WHEN signIn THEN error password is shown */
- @Test
- fun emptyPasswordShowsProperErrorMessage() {
- }
-
- /** GIVEN password and empty username WHEN signIn THEN error username is shown */
- @Test
- fun emptyUserNameShowsProperErrorMessage() {
- }
-
- /** GIVEN password and username and invalid credentials response WHEN signIn THEN error invalid credentials is shown */
- @Test
- fun invalidCredentialsGivenShowsProperErrorMessage() {
- }
-
- /** GIVEN password and username and error response WHEN signIn THEN error invalid credentials is shown */
- @Test
- fun networkErrorShowsProperErrorMessage() {
- }
-}
diff --git a/app/src/sharedTest/java/org/fnives/test/showcase/ui/login/codekata/CodeKataSharedRobotTest.kt b/app/src/sharedTest/java/org/fnives/test/showcase/ui/login/codekata/CodeKataSharedRobotTest.kt
deleted file mode 100644
index 2123cab..0000000
--- a/app/src/sharedTest/java/org/fnives/test/showcase/ui/login/codekata/CodeKataSharedRobotTest.kt
+++ /dev/null
@@ -1,69 +0,0 @@
-package org.fnives.test.showcase.ui.login.codekata
-
-import androidx.annotation.StringRes
-import androidx.test.espresso.Espresso
-import androidx.test.espresso.action.ViewActions
-import androidx.test.espresso.assertion.ViewAssertions
-import androidx.test.espresso.intent.Intents
-import androidx.test.espresso.intent.matcher.IntentMatchers
-import androidx.test.espresso.matcher.ViewMatchers
-import org.fnives.test.showcase.R
-import org.fnives.test.showcase.android.testutil.intent.notIntended
-import org.fnives.test.showcase.android.testutil.snackbar.SnackbarVerificationHelper.assertSnackBarIsNotShown
-import org.fnives.test.showcase.android.testutil.snackbar.SnackbarVerificationHelper.assertSnackBarIsShownWithText
-import org.fnives.test.showcase.ui.home.MainActivity
-import org.hamcrest.core.IsNot
-
-class CodeKataSharedRobotTest {
-
- fun setUsername(username: String): CodeKataSharedRobotTest = apply {
- Espresso.onView(ViewMatchers.withId(R.id.user_edit_text))
- .perform(ViewActions.replaceText(username), ViewActions.closeSoftKeyboard())
- }
-
- fun setPassword(password: String): CodeKataSharedRobotTest = apply {
- Espresso.onView(ViewMatchers.withId(R.id.password_edit_text))
- .perform(ViewActions.replaceText(password), ViewActions.closeSoftKeyboard())
- }
-
- fun clickOnLogin(): CodeKataSharedRobotTest = apply {
- Espresso.onView(ViewMatchers.withId(R.id.login_cta))
- .perform(ViewActions.click())
- }
-
- fun assertPassword(password: String): CodeKataSharedRobotTest = apply {
- Espresso.onView(ViewMatchers.withId((R.id.password_edit_text)))
- .check(ViewAssertions.matches(ViewMatchers.withText(password)))
- }
-
- fun assertUsername(username: String): CodeKataSharedRobotTest = apply {
- Espresso.onView(ViewMatchers.withId((R.id.user_edit_text)))
- .check(ViewAssertions.matches(ViewMatchers.withText(username)))
- }
-
- fun assertLoadingBeforeRequests(): CodeKataSharedRobotTest = apply {
- Espresso.onView(ViewMatchers.withId(R.id.loading_indicator))
- .check(ViewAssertions.matches(ViewMatchers.isDisplayed()))
- }
-
- fun assertNotLoading(): CodeKataSharedRobotTest = apply {
- Espresso.onView(ViewMatchers.withId(R.id.loading_indicator))
- .check(ViewAssertions.matches(IsNot.not(ViewMatchers.isDisplayed())))
- }
-
- fun assertErrorIsShown(@StringRes stringResID: Int): CodeKataSharedRobotTest = apply {
- assertSnackBarIsShownWithText(stringResID)
- }
-
- fun assertErrorIsNotShown(): CodeKataSharedRobotTest = apply {
- assertSnackBarIsNotShown()
- }
-
- fun assertNavigatedToHome(): CodeKataSharedRobotTest = apply {
- Intents.intended(IntentMatchers.hasComponent(MainActivity::class.java.canonicalName))
- }
-
- fun assertNotNavigatedToHome(): CodeKataSharedRobotTest = apply {
- notIntended(IntentMatchers.hasComponent(MainActivity::class.java.canonicalName))
- }
-}
diff --git a/app/src/sharedTest/java/org/fnives/test/showcase/ui/login/codekata/rule/dispatcher/CodeKataMainDispatcherRule.kt b/app/src/sharedTest/java/org/fnives/test/showcase/ui/login/codekata/rule/dispatcher/CodeKataMainDispatcherRule.kt
deleted file mode 100644
index fafb8d9..0000000
--- a/app/src/sharedTest/java/org/fnives/test/showcase/ui/login/codekata/rule/dispatcher/CodeKataMainDispatcherRule.kt
+++ /dev/null
@@ -1,16 +0,0 @@
-package org.fnives.test.showcase.ui.login.codekata.rule.dispatcher
-
-import kotlinx.coroutines.ExperimentalCoroutinesApi
-import org.junit.rules.TestRule
-import org.junit.runner.Description
-import org.junit.runners.model.Statement
-
-@OptIn(ExperimentalCoroutinesApi::class)
-class CodeKataMainDispatcherRule : TestRule {
- override fun apply(base: Statement, description: Description): Statement =
- object : Statement() {
- override fun evaluate() {
- TODO("Not yet implemented")
- }
- }
-}
diff --git a/app/src/sharedTest/java/org/fnives/test/showcase/ui/login/codekata/rule/dispatcher/PlainMainDispatcherRule.kt b/app/src/sharedTest/java/org/fnives/test/showcase/ui/login/codekata/rule/dispatcher/PlainMainDispatcherRule.kt
deleted file mode 100644
index bb3f10d..0000000
--- a/app/src/sharedTest/java/org/fnives/test/showcase/ui/login/codekata/rule/dispatcher/PlainMainDispatcherRule.kt
+++ /dev/null
@@ -1,41 +0,0 @@
-package org.fnives.test.showcase.ui.login.codekata.rule.dispatcher
-
-import kotlinx.coroutines.Dispatchers
-import kotlinx.coroutines.ExperimentalCoroutinesApi
-import kotlinx.coroutines.test.StandardTestDispatcher
-import kotlinx.coroutines.test.TestDispatcher
-import kotlinx.coroutines.test.UnconfinedTestDispatcher
-import kotlinx.coroutines.test.resetMain
-import kotlinx.coroutines.test.setMain
-import org.fnives.test.showcase.storage.database.DatabaseInitialization
-import org.fnives.test.showcase.testutils.storage.TestDatabaseInitialization
-import org.junit.rules.TestRule
-import org.junit.runner.Description
-import org.junit.runners.model.Statement
-
-/**
- * Sets up the Dispatcher as Main and as the [DatabaseInitialization]'s dispatcher.
- */
-@OptIn(ExperimentalCoroutinesApi::class)
-class PlainMainDispatcherRule(private val useStandard: Boolean = true) : TestRule {
-
- private var _testDispatcher: TestDispatcher? = null
- val testDispatcher
- get() = _testDispatcher
- ?: throw IllegalStateException("TestDispatcher is accessed before it is initialized!")
-
- override fun apply(base: Statement, description: Description): Statement = object : Statement() {
- override fun evaluate() {
- try {
- val dispatcher = if (useStandard) StandardTestDispatcher() else UnconfinedTestDispatcher()
- Dispatchers.setMain(dispatcher)
- TestDatabaseInitialization.overwriteDatabaseInitialization(dispatcher)
- _testDispatcher = dispatcher
- base.evaluate()
- } finally {
- _testDispatcher = null
- Dispatchers.resetMain()
- }
- }
- }
-}
diff --git a/app/src/sharedTest/java/org/fnives/test/showcase/ui/login/codekata/rule/intent/CodeKataIntentInitRule.kt b/app/src/sharedTest/java/org/fnives/test/showcase/ui/login/codekata/rule/intent/CodeKataIntentInitRule.kt
deleted file mode 100644
index 05ba399..0000000
--- a/app/src/sharedTest/java/org/fnives/test/showcase/ui/login/codekata/rule/intent/CodeKataIntentInitRule.kt
+++ /dev/null
@@ -1,11 +0,0 @@
-package org.fnives.test.showcase.ui.login.codekata.rule.intent
-
-import org.junit.rules.TestRule
-import org.junit.runner.Description
-import org.junit.runners.model.Statement
-
-class CodeKataIntentInitRule : TestRule {
- override fun apply(base: Statement, description: Description): Statement {
- TODO()
- }
-}
diff --git a/app/src/sharedTest/java/org/fnives/test/showcase/ui/login/codekata/rule/intent/PlainIntentInitRule.kt b/app/src/sharedTest/java/org/fnives/test/showcase/ui/login/codekata/rule/intent/PlainIntentInitRule.kt
deleted file mode 100644
index ee054f8..0000000
--- a/app/src/sharedTest/java/org/fnives/test/showcase/ui/login/codekata/rule/intent/PlainIntentInitRule.kt
+++ /dev/null
@@ -1,25 +0,0 @@
-package org.fnives.test.showcase.ui.login.codekata.rule.intent
-
-import androidx.test.espresso.intent.Intents
-import org.junit.rules.TestRule
-import org.junit.runner.Description
-import org.junit.runners.model.Statement
-
-/**
- * Takes care of [Intents] initialization.
- */
-class PlainIntentInitRule : TestRule {
- override fun apply(base: Statement, description: Description): Statement {
- return object : Statement() {
- @Throws(Throwable::class)
- override fun evaluate() {
- try {
- Intents.init()
- base.evaluate()
- } finally {
- Intents.release()
- }
- }
- }
- }
-}
diff --git a/gradlescripts/testdependencies.gradle b/gradlescripts/testdependencies.gradle
index f4ce4b8..ef2187d 100644
--- a/gradlescripts/testdependencies.gradle
+++ b/gradlescripts/testdependencies.gradle
@@ -21,6 +21,10 @@ project.ext {
applyAppTestDependenciesTo(this)
applyComposeTestDependenciesTo(this) // if you are using compose
}
+ -------------APP-SHARED-TEST(Android Module-------------
+ dependencies {
+ applyAppSharedTestDependenciesTo(this)
+ }
------------------VERSIONS------------------
versions try to get the global value, if not found they fall back to some defaults.
@@ -77,18 +81,24 @@ project.ext {
]
// ------------------PRIVATE------------------
- def applyStandardTestDependenciesTo = { module ->
- module.dependencies {
+ def standardTestDependencies = [
// coroutine testing
- testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:$test_coroutines_version"
+ "org.jetbrains.kotlinx:kotlinx-coroutines-test:$test_coroutines_version",
// mockito, mocking library
- testImplementation "org.mockito.kotlin:mockito-kotlin:$testing_kotlin_mockito_version"
+ "org.mockito.kotlin:mockito-kotlin:$testing_kotlin_mockito_version",
- testImplementation "io.insert-koin:koin-test-junit5:$testing_koin_version"
+ "io.insert-koin:koin-test-junit5:$testing_koin_version",
// junit5
- testImplementation "org.junit.jupiter:junit-jupiter-engine:$testing_junit5_version"
- testImplementation "org.junit.jupiter:junit-jupiter-params:$testing_junit5_version"
+ "org.junit.jupiter:junit-jupiter-engine:$testing_junit5_version",
+ "org.junit.jupiter:junit-jupiter-params:$testing_junit5_version",
+ ]
+
+ def applyStandardTestDependenciesTo = { module ->
+ module.dependencies {
+ standardTestDependencies.forEach { dependency ->
+ testImplementation dependency
+ }
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$testing_junit5_version"
}
}
@@ -137,6 +147,21 @@ project.ext {
}
}
+ // ------------APP-SHARED-TEST------------
+ applyAppSharedTestDependenciesTo = { module ->
+
+ module.dependencies {
+ standardTestDependencies.forEach { dependency ->
+ implementation dependency
+ }
+ androidSpecificTestDependencies.forEach { dependency ->
+ implementation dependency
+ }
+ implementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:$test_coroutines_version"
+ implementation "io.insert-koin:koin-test-junit5:$testing_koin_version"
+ }
+ }
+
// ------------------COMPOSE------------------
applyComposeTestDependenciesTo = { module ->
module.dependencies {
diff --git a/settings.gradle b/settings.gradle
index d372230..2e425d3 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -8,4 +8,5 @@ include ':test-util-shared-android'
include ':test-util-shared-robolectric'
include ':test-util-android'
include ':test-util-junit5-android'
+include ':app-shared-test'
include ':examplecase:example-navcontroller'