diff --git a/composer/build.gradle b/composer/build.gradle index 1fda0ca..d03471f 100644 --- a/composer/build.gradle +++ b/composer/build.gradle @@ -16,6 +16,7 @@ dependencies { compile libraries.apacheCommonsIo compile libraries.apacheCommonsLang compile libraries.gson + compile libraries.dexParser } dependencies { diff --git a/composer/src/main/kotlin/com/gojuno/composer/Apk.kt b/composer/src/main/kotlin/com/gojuno/composer/Apk.kt index 479605a..664cb8b 100644 --- a/composer/src/main/kotlin/com/gojuno/composer/Apk.kt +++ b/composer/src/main/kotlin/com/gojuno/composer/Apk.kt @@ -3,6 +3,7 @@ package com.gojuno.composer import com.gojuno.commander.android.aapt import com.gojuno.commander.os.Notification import com.gojuno.commander.os.process +import com.linkedin.dex.parser.DexParser sealed class TestPackage { data class Valid(val value: String) : TestPackage() @@ -61,4 +62,7 @@ fun parseTestRunner(testApkPath: String): TestRunner = } .toSingle() .toBlocking() - .value() \ No newline at end of file + .value() + +fun parseTests(testApkPath: String): List = + DexParser.findTestMethods(testApkPath).map { TestMethod(it.testName, it.annotationNames) } diff --git a/composer/src/main/kotlin/com/gojuno/composer/Main.kt b/composer/src/main/kotlin/com/gojuno/composer/Main.kt index f73b8bd..296513d 100644 --- a/composer/src/main/kotlin/com/gojuno/composer/Main.kt +++ b/composer/src/main/kotlin/com/gojuno/composer/Main.kt @@ -198,6 +198,9 @@ private fun List.pairArguments(): List> = } } +private fun buildSingleTestArguments(testMethod : String) : List> = + listOf("class" to testMethod) + private fun buildShardArguments(shardingOn: Boolean, shardIndex: Int, devices: Int): List> = when { shardingOn && devices > 1 -> listOf( "numShards" to "$devices", diff --git a/composer/src/main/kotlin/com/gojuno/composer/TestMethod.kt b/composer/src/main/kotlin/com/gojuno/composer/TestMethod.kt new file mode 100644 index 0000000..b6532a2 --- /dev/null +++ b/composer/src/main/kotlin/com/gojuno/composer/TestMethod.kt @@ -0,0 +1,3 @@ +package com.gojuno.composer + +data class TestMethod(val testName: String, val annotationNames: List) \ No newline at end of file diff --git a/composer/src/test/kotlin/com/gojuno/composer/ApkSpec.kt b/composer/src/test/kotlin/com/gojuno/composer/ApkSpec.kt index b42120a..9675148 100644 --- a/composer/src/test/kotlin/com/gojuno/composer/ApkSpec.kt +++ b/composer/src/test/kotlin/com/gojuno/composer/ApkSpec.kt @@ -18,5 +18,13 @@ class ApkSpec : Spek({ it("parses test package correctly") { assertThat(parseTestPackage(testApkPath)).isEqualTo(TestPackage.Valid("test.test.myapplication.test")) } + + it("parses tests list correctly") { + assertThat(parseTests(testApkPath)).isEqualTo(listOf( + TestMethod("test.test.myapplication.ExampleInstrumentedTest#useAppContext", + listOf("dalvik.annotation.Throws", "org.junit.Test", "org.junit.runner.RunWith") + ) + )) + } } -}) +}) \ No newline at end of file diff --git a/dependencies.gradle b/dependencies.gradle index 4bc9e4c..746ca18 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -7,6 +7,7 @@ ext.versions = [ apacheCommonsIo : '2.5', apacheCommonsLang: '3.5', gson : '2.8.0', + dexParser : '1.1.0', junit : '4.12', junitPlatform : '1.0.0-M4', @@ -26,6 +27,7 @@ ext.libraries = [ apacheCommonsIo : "commons-io:commons-io:$versions.apacheCommonsIo", apacheCommonsLang : "org.apache.commons:commons-lang3:$versions.apacheCommonsLang", gson : "com.google.code.gson:gson:$versions.gson", + dexParser : "com.linkedin.dextestparser:parser:$versions.dexParser", junit : "junit:junit:$versions.junit", spek : "org.jetbrains.spek:spek-api:$versions.spek",