Skip to content
This repository has been archived by the owner on Dec 7, 2019. It is now read-only.

[WIP] "Orchestrator like" execution mode #138

Merged
merged 12 commits into from
Apr 25, 2018
1 change: 1 addition & 0 deletions composer/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ dependencies {
compile libraries.apacheCommonsIo
compile libraries.apacheCommonsLang
compile libraries.gson
compile libraries.dexParser
}

dependencies {
Expand Down
6 changes: 5 additions & 1 deletion composer/src/main/kotlin/com/gojuno/composer/Apk.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -61,4 +62,7 @@ fun parseTestRunner(testApkPath: String): TestRunner =
}
.toSingle()
.toBlocking()
.value()
.value()

fun parseTests(testApkPath: String): List<TestMethod> =
DexParser.findTestMethods(testApkPath).map { TestMethod(it.testName, it.annotationNames) }
3 changes: 3 additions & 0 deletions composer/src/main/kotlin/com/gojuno/composer/Main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,9 @@ private fun List<String>.pairArguments(): List<Pair<String, String>> =
}
}

private fun buildSingleTestArguments(testMethod : String) : List<Pair<String,String>> =
listOf("class" to testMethod)

private fun buildShardArguments(shardingOn: Boolean, shardIndex: Int, devices: Int): List<Pair<String, String>> = when {
shardingOn && devices > 1 -> listOf(
"numShards" to "$devices",
Expand Down
3 changes: 3 additions & 0 deletions composer/src/main/kotlin/com/gojuno/composer/TestMethod.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package com.gojuno.composer

data class TestMethod(val testName: String, val annotationNames: List<String>)
10 changes: 9 additions & 1 deletion composer/src/test/kotlin/com/gojuno/composer/ApkSpec.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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")
)
))
}
}
})
})
2 changes: 2 additions & 0 deletions dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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",
Expand Down