diff --git a/examplecase/example-navcontroller-shared-test/.gitignore b/examplecase/example-navcontroller-shared-test/.gitignore
new file mode 100644
index 0000000..42afabf
--- /dev/null
+++ b/examplecase/example-navcontroller-shared-test/.gitignore
@@ -0,0 +1 @@
+/build
\ No newline at end of file
diff --git a/examplecase/example-navcontroller-shared-test/build.gradle b/examplecase/example-navcontroller-shared-test/build.gradle
new file mode 100644
index 0000000..b05fb63
--- /dev/null
+++ b/examplecase/example-navcontroller-shared-test/build.gradle
@@ -0,0 +1,44 @@
+plugins {
+ id 'com.android.library'
+ id 'org.jetbrains.kotlin.android'
+ id 'androidx.navigation.safeargs.kotlin'
+}
+
+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'
+ }
+ }
+ compileOptions {
+ sourceCompatibility JavaVersion.VERSION_1_8
+ targetCompatibility JavaVersion.VERSION_1_8
+ }
+ kotlinOptions {
+ jvmTarget = '1.8'
+ }
+
+ lintOptions {
+ ignore 'FragmentGradleConfiguration'
+ }
+}
+
+dependencies {
+ applyAppSharedTestDependenciesTo(this)
+ implementation project(":examplecase:example-navcontroller")
+ //noinspection FragmentGradleConfiguration
+ implementation "androidx.fragment:fragment-testing:1.5.3"
+ implementation "androidx.navigation:navigation-testing:$navigation_version"
+ implementation project(':test-util-android')
+}
\ No newline at end of file
diff --git a/examplecase/example-navcontroller-shared-test/consumer-rules.pro b/examplecase/example-navcontroller-shared-test/consumer-rules.pro
new file mode 100644
index 0000000..e69de29
diff --git a/examplecase/example-navcontroller-shared-test/proguard-rules.pro b/examplecase/example-navcontroller-shared-test/proguard-rules.pro
new file mode 100644
index 0000000..481bb43
--- /dev/null
+++ b/examplecase/example-navcontroller-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/examplecase/example-navcontroller-shared-test/src/main/AndroidManifest.xml b/examplecase/example-navcontroller-shared-test/src/main/AndroidManifest.xml
new file mode 100644
index 0000000..6f663a2
--- /dev/null
+++ b/examplecase/example-navcontroller-shared-test/src/main/AndroidManifest.xml
@@ -0,0 +1,5 @@
+
+
+
+
\ No newline at end of file
diff --git a/examplecase/example-navcontroller/src/sharedTest/java/org/fnives/test/showcase/examplecase/navcontroller/HomeNavigationTest.kt b/examplecase/example-navcontroller-shared-test/src/main/java/org/fnives/test/showcase/examplecase/navcontroller/HomeNavigationSharedTest.kt
similarity index 90%
rename from examplecase/example-navcontroller/src/sharedTest/java/org/fnives/test/showcase/examplecase/navcontroller/HomeNavigationTest.kt
rename to examplecase/example-navcontroller-shared-test/src/main/java/org/fnives/test/showcase/examplecase/navcontroller/HomeNavigationSharedTest.kt
index 6943f0f..45143ba 100644
--- a/examplecase/example-navcontroller/src/sharedTest/java/org/fnives/test/showcase/examplecase/navcontroller/HomeNavigationTest.kt
+++ b/examplecase/example-navcontroller-shared-test/src/main/java/org/fnives/test/showcase/examplecase/navcontroller/HomeNavigationSharedTest.kt
@@ -28,7 +28,7 @@ import org.junit.runner.RunWith
* For more info check out https://developer.android.com/guide/navigation/navigation-testing
*/
@RunWith(AndroidJUnit4::class)
-class HomeNavigationTest {
+open class HomeNavigationSharedTest {
private lateinit var fragmentScenario: FragmentScenario
private lateinit var testNavController: TestNavHostController
@@ -80,7 +80,8 @@ class HomeNavigationTest {
.perform(ViewActions.click())
Assert.assertEquals(R.id.detailFragment, testNavController.currentDestination?.id)
- Assert.assertEquals(listOf(R.id.nav_example_xml, R.id.homeFragment, R.id.detailFragment), testNavController.backStack.map { it.destination.id })
+ val expectedBackstack = listOf(R.id.nav_example_xml, R.id.homeFragment, R.id.detailFragment)
+ Assert.assertEquals(expectedBackstack, testNavController.backStack.map { it.destination.id })
testNavController.backStack.map { it.arguments }
}
@@ -95,7 +96,8 @@ class HomeNavigationTest {
Espresso.onView(itemViewMatcher(position2)).perform(ViewActions.click())
Assert.assertEquals(R.id.detailFragment, testNavController.currentDestination?.id)
- Assert.assertEquals(listOf(R.id.nav_example_xml, R.id.homeFragment, R.id.detailFragment), testNavController.backStack.map { it.destination.id })
+ val expectedBackstack = listOf(R.id.nav_example_xml, R.id.homeFragment, R.id.detailFragment)
+ Assert.assertEquals(expectedBackstack, testNavController.backStack.map { it.destination.id })
val actualArgs = DetailFragmentArgs.fromBundle(testNavController.backStack.last().arguments ?: Bundle())
Assert.assertEquals(position1, actualArgs.position)
}
diff --git a/examplecase/example-navcontroller/build.gradle b/examplecase/example-navcontroller/build.gradle
index 914af41..323fbee 100644
--- a/examplecase/example-navcontroller/build.gradle
+++ b/examplecase/example-navcontroller/build.gradle
@@ -28,17 +28,6 @@ android {
kotlinOptions {
jvmTarget = '1.8'
}
- sourceSets {
- androidTest {
- java.srcDirs += "src/sharedTest/java"
- assets.srcDirs += files("$projectDir/schemas".toString())
- }
- test {
- java.srcDirs += "src/sharedTest/java"
- java.srcDirs += "src/robolectricTest/java"
- resources.srcDirs += files("$projectDir/schemas".toString())
- }
- }
// needed for androidTest
packagingOptions {
@@ -56,12 +45,8 @@ dependencies {
implementation "androidx.navigation:navigation-fragment-ktx:$navigation_version"
implementation "androidx.navigation:navigation-ui-ktx:$navigation_version"
- debugImplementation "androidx.fragment:fragment-testing:1.5.3"
-
applyAppTestDependenciesTo(this)
-
- testImplementation "androidx.navigation:navigation-testing:$navigation_version"
- testImplementation project(':test-util-android')
- androidTestImplementation project(':test-util-android')
- androidTestImplementation "androidx.navigation:navigation-testing:$navigation_version"
+ debugImplementation "androidx.fragment:fragment-testing:1.5.3"
+ testImplementation project(":examplecase:example-navcontroller-shared-test")
+ androidTestImplementation project(":examplecase:example-navcontroller-shared-test")
}
\ No newline at end of file
diff --git a/examplecase/example-navcontroller/src/androidTest/java/org/fnives/test/showcase/examplecase/navcontroller/HomeNavigationTest.kt b/examplecase/example-navcontroller/src/androidTest/java/org/fnives/test/showcase/examplecase/navcontroller/HomeNavigationTest.kt
new file mode 100644
index 0000000..b2de66d
--- /dev/null
+++ b/examplecase/example-navcontroller/src/androidTest/java/org/fnives/test/showcase/examplecase/navcontroller/HomeNavigationTest.kt
@@ -0,0 +1,7 @@
+package org.fnives.test.showcase.examplecase.navcontroller
+
+import androidx.test.ext.junit.runners.AndroidJUnit4
+import org.junit.runner.RunWith
+
+@RunWith(AndroidJUnit4::class)
+class HomeNavigationTest : HomeNavigationSharedTest()
diff --git a/examplecase/example-navcontroller/src/test/java/org/fnives/test/showcase/examplecase/navcontroller/HomeNavigationTest.kt b/examplecase/example-navcontroller/src/test/java/org/fnives/test/showcase/examplecase/navcontroller/HomeNavigationTest.kt
new file mode 100644
index 0000000..b2de66d
--- /dev/null
+++ b/examplecase/example-navcontroller/src/test/java/org/fnives/test/showcase/examplecase/navcontroller/HomeNavigationTest.kt
@@ -0,0 +1,7 @@
+package org.fnives.test.showcase.examplecase.navcontroller
+
+import androidx.test.ext.junit.runners.AndroidJUnit4
+import org.junit.runner.RunWith
+
+@RunWith(AndroidJUnit4::class)
+class HomeNavigationTest : HomeNavigationSharedTest()
diff --git a/settings.gradle b/settings.gradle
index 2e425d3..1306dfa 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -10,3 +10,4 @@ include ':test-util-android'
include ':test-util-junit5-android'
include ':app-shared-test'
include ':examplecase:example-navcontroller'
+include ':examplecase:example-navcontroller-shared-test'