Repository: runningcode/fladle
Pull request #120 (2020-05-16 22:21:14)

Fix additionalTestApks docs and implementation.


Patch:
diff --git a/buildSrc/src/main/java/com/osacky/flank/gradle/YamlWriter.kt b/buildSrc/src/main/java/com/osacky/flank/gradle/YamlWriter.kt
index a4797c0..41495d6 100644
--- a/buildSrc/src/main/java/com/osacky/flank/gradle/YamlWriter.kt
+++ b/buildSrc/src/main/java/com/osacky/flank/gradle/YamlWriter.kt
@@ -66,7 +66,7 @@ internal class YamlWriter {
     if (additionalTestApks.isNotEmpty()) {
       appendln("  additional-app-test-apks:")
       additionalTestApks.forEach {
-        appendln("    - $it")
+        appendln("    $it")
       }
     }
 
diff --git a/docs/configuration.md b/docs/configuration.md
index 858e6d2..b07b58d 100644
--- a/docs/configuration.md
+++ b/docs/configuration.md
@@ -65,7 +65,11 @@ fladle {
     flankVersion = "20.05.1"
     debugApk = "$buildDir/outputs/apk/debug/sample-debug.apk"
     instrumentationApk = "$buildDir/outputs/apk/androidTest/debug/sample-debug-androidTest.apk"
-    additionalTestApks = ["$buildDir/outputs/apk/debug/sample-debug.apk": ["$buildDir/outputs/apk/androidTest/debug/sample2-debug-androidTest.apk"]]
+    additionalTestApks = [
+        "- app: "$buildDir/outputs/apk/debug/sample-debug.apk",
+        "  test: $buildDir/outputs/apk/androidTest/debug/sample2-debug-androidTest.apk",
+        "- test: ${rootProject.buildDir}/database/module/outputs/apk/database-module-androidTest.apk"
+    ]
     autoGoogleLogin = true
     testShards = 5 //or numUniformShards=5 cannot use both
     shardTime = 120
@@ -162,28 +166,29 @@ Optional, prefer to set [variant](/configuration#variant).
 ### additionalTestApks
 Paths to additional test configurations.
 Order matters. A test apk is run with the nearest previous listed app apk.
+For library modules, add them to the list with a `- test:` in front. For test apks which belong to an application module, add them with `  test:`.
 It is not required to list an app apk here. If there is no app apk listed in additionalTestApks, the test apks are run against the [debugApk](#debugapk).
 
 === "Groovy"
     ```groovy
     additionalTestApks.value(project.provider { [
-    "app: ../main/app/build/output/apk/debug/app.apk",
-    "test: ../main/app/build/output/apk/androidTest/debug/app-test.apk",
-    "app: ../sample/app/build/output/apk/debug/sample-app.apk",
-    "test: ../sample/app/build/output/apk/androidTest/debug/sample-app-test.apk",
-    "test: ../feature/room/build/output/apk/androidTest/debug/feature-room-test.apk",
-    "test: ../library/databases/build/output/apk/androidTest/debug/sample-databases-test.apk"
+    "- app: ../main/app/build/output/apk/debug/app.apk",
+    "  test: ../main/app/build/output/apk/androidTest/debug/app-test.apk",
+    "- app: ../sample/app/build/output/apk/debug/sample-app.apk",
+    "  test: ../sample/app/build/output/apk/androidTest/debug/sample-app-test.apk",
+    "- test: ../feature/room/build/output/apk/androidTest/debug/feature-room-test.apk",
+    "- test: ../library/databases/build/output/apk/androidTest/debug/sample-databases-test.apk"
     ]})
     ```
 === "Kotlin"
     ``` kotlin
     additionalTestApks.value(project.provider { listOf(
-    "app: ../main/app/build/output/apk/debug/app.apk",
-    "test: ../main/app/build/output/apk/androidTest/debug/app-test.apk",
-    "app: ../sample/app/build/output/apk/debug/sample-app.apk",
-    "test: ../sample/app/build/output/apk/androidTest/debug/sample-app-test.apk",
-    "test: ../feature/room/build/output/apk/androidTest/debug/feature-room-test.apk",
-    "test: ../library/databases/build/output/apk/androidTest/debug/sample-databases-test.apk"
+    "- app: ../main/app/build/output/apk/debug/app.apk",
+    "  test: ../main/app/build/output/apk/androidTest/debug/app-test.apk",
+    "- app: ../sample/app/build/output/apk/debug/sample-app.apk",
+    "  test: ../sample/app/build/output/apk/androidTest/debug/sample-app-test.apk",
+    "- test: ../feature/room/build/output/apk/androidTest/debug/feature-room-test.apk",
+    "- test: ../library/databases/build/output/apk/androidTest/debug/sample-databases-test.apk"
     )})
     ```
 ### autoGoogleLogin


Test patch:
diff --git a/buildSrc/src/test/java/com/osacky/flank/gradle/YamlWriterTest.kt b/buildSrc/src/test/java/com/osacky/flank/gradle/YamlWriterTest.kt
index 59f1270..00267f9 100644
--- a/buildSrc/src/test/java/com/osacky/flank/gradle/YamlWriterTest.kt
+++ b/buildSrc/src/test/java/com/osacky/flank/gradle/YamlWriterTest.kt
@@ -608,41 +608,41 @@ class YamlWriterTest {
       )
   }
 
-    @Test
-    fun writeAdditionalTestApks() {
-        val extension = emptyExtension {
-            debugApk.set("../orange/build/output/app.apk")
-            instrumentationApk.set("../orange/build/output/app-test.apk")
-            additionalTestApks.set(project.provider {
-                listOf(
-                    "app: ../orange/build/output/app.apk",
-                    "test: ../orange/build/output/app-test2.apk",
-                    "app: ../bob/build/output/app.apk",
-                    "test: ../bob/build/output/app-test.apk",
-                    "test: ../bob/build/output/app-test2.apk",
-                    "test: ../bob/build/output/app-test3.apk"
-                )
-            })
-        }
-
-        assertThat(
-            yamlWriter.writeFlankProperties(extension)).isEqualTo(
-            """
+  @Test
+  fun writeAdditionalTestApks() {
+    val extension = emptyExtension {
+      debugApk.set("../orange/build/output/app.apk")
+      instrumentationApk.set("../orange/build/output/app-test.apk")
+      additionalTestApks.set(project.provider {
+        listOf(
+            "- app: ../orange/build/output/app.apk",
+            "  test: ../orange/build/output/app-test2.apk",
+            "- app: ../bob/build/output/app.apk",
+            "  test: ../bob/build/output/app-test.apk",
+            "- test: ../bob/build/output/app-test2.apk",
+            "- test: ../bob/build/output/app-test3.apk"
+        )
+      })
+    }
+
+    assertThat(
+        yamlWriter.writeFlankProperties(extension)).isEqualTo(
+        """
              flank:
                keep-file-path: false
                additional-app-test-apks:
                  - app: ../orange/build/output/app.apk
-                 - test: ../orange/build/output/app-test2.apk
+                   test: ../orange/build/output/app-test2.apk
                  - app: ../bob/build/output/app.apk
-                 - test: ../bob/build/output/app-test.apk
+                   test: ../bob/build/output/app-test.apk
                  - test: ../bob/build/output/app-test2.apk
                  - test: ../bob/build/output/app-test3.apk
                ignore-failed-tests: false
                disable-sharding: false
                smart-flank-disable-upload: false
           """.trimIndent() + '\n'
-        )
-    }
+    )
+  }
 
   @Test
   fun verifyDefaultValues() {