Added parsing of test runner and test package from apk-s.#119
Added parsing of test runner and test package from apk-s.#119yunikkk merged 1 commit intogojuno:masterfrom
Conversation
9c85309 to
2a6edcc
Compare
| ) | ||
| var testPackage: String = "", | ||
|
|
||
| @Parameter( |
There was a problem hiding this comment.
@artem-zinnatullin not sure if we still need that argument. I can imagine choosing from multiple runners in one test apk, though use cases are not clear. WDYT?
There was a problem hiding this comment.
Since it's now optional I'd leave it, but we need to update README and remove it from examples
artem-zinnatullin
left a comment
There was a problem hiding this comment.
I guess weed is now legal in Belarus or I don't understand something lol
| ) | ||
| var testPackage: String = "", | ||
|
|
||
| @Parameter( |
There was a problem hiding this comment.
Since it's now optional I'd leave it, but we need to update README and remove it from examples
| names = arrayOf("--verbose-output"), | ||
| required = false, | ||
| arity = 1, | ||
| description = "Either `true` or `false` to enable/disable verbose output for Composer. `false` by default.", |
There was a problem hiding this comment.
I liked "Either x or y" part, otherwise it's not obvious that you can pass booleans
There was a problem hiding this comment.
Okay, will return it.
| required = false, | ||
| description = "APK installation timeout in seconds. If not passed defaults to 120 seconds (2 minutes). Applicable to both test APK and APK under test.", | ||
| order = 11 | ||
| order = 10 |
There was a problem hiding this comment.
I honestly don't remember why order is important here and certainly don't like that we need to maintain it manually..
There was a problem hiding this comment.
Args are sorted alphabetically in -help without order specified =(
| log("$args") | ||
| } | ||
|
|
||
| val testPackage = getTestPackageFromTestApk(args.testApkPath) |
There was a problem hiding this comment.
rename to parseTestPackage(testApkFile = File(args.testApkPath))?
| .toList() | ||
| .flatMap { | ||
| val testRunner = if (args.testRunner.isEmpty()) { | ||
| device.getTestRunnerForInstalledTestApk(testPackage) |
There was a problem hiding this comment.
querying every device to get info that we can parse from apk looks very strange to me O_o
| val totalPassed = suites.sumBy { it.passedCount } | ||
| val totalFailed = suites.sumBy { it.failedCount } | ||
| val totalIgnored = suites.sumBy { it.ignoredCount } | ||
| fun AdbDevice.getTestRunnerFromTestApk(): Single<String> = |
There was a problem hiding this comment.
wuuut, why do we need to query device for that?
Can't we parse it from apk? This info should be in the manifest
There was a problem hiding this comment.
Well, mostly, it seemed to be the simpler way.
However, I've just found that aapt is capable of parsing the whole manifest as well, so we won't need to do it manually.
Will change it then.
PS. Actually getTestRunnerFromTestApk is duplicating getTestRunnerForInstalledTestApk defined below, its just and old one.
| .toSingle() | ||
|
|
||
| log("Test run finished, total passed = $totalPassed, total failed = $totalFailed, total ignored = $totalIgnored, took ${duration.nanosToHumanReadableTime()}.") | ||
| private fun getTestPackageFromTestApk(testApkPath: String): String = |
There was a problem hiding this comment.
we need a test for that maaaan
There was a problem hiding this comment.
you can just drop dummy apk into test/resources or even add a dummy android module to the project and use its build results as test input
| else -> exit(Exit.ThereWereFailedTests) | ||
| } | ||
| } | ||
| private fun AdbDevice.getTestRunnerForInstalledTestApk(testPackage: String): String = |
There was a problem hiding this comment.
same question here, why not parse it from apk?
|
narkoman chto li |
|
niet. |
6589816 to
c224516
Compare
| output | ||
| .readText() | ||
| .split(System.lineSeparator()) | ||
| // output format `package: name='$testPackage' versionCode='' versionName='' platformBuildVersionName='xxx'` |
There was a problem hiding this comment.
nice comment, lois
| .first { it.startsWith("name=") } | ||
| .split("'")[1] | ||
| } | ||
| .onErrorReturn { "" } |
There was a problem hiding this comment.
Lets propagate error up or make a sealed class for result? Otherwise we're kinda using one possible state of string as error indicator
| import com.gojuno.commander.os.Notification | ||
| import com.gojuno.commander.os.process | ||
|
|
||
| fun parseTestPackage(testApkPath: String): String = |
There was a problem hiding this comment.
I'd expose it as Single<String>, up2u
|
|
||
| val testApkPath by memoized { fileFromJarResources<InstrumentationSpec>("instrumentation-test.apk").absolutePath } | ||
|
|
||
| it("test runner is parsed correctly") { |
There was a problem hiding this comment.
it("parses test runner correctly"), ingilish, do u speak it?
| assertThat(getTestRunner(testApkPath)).isEqualTo("android.support.test.runner.AndroidJUnitRunner") | ||
| } | ||
|
|
||
| it("test package is parsed correctly") { |
c224516 to
27f6c65
Compare
|
@artem-zinnatullin PTAL |
| ?.split(" ") | ||
| ?.firstOrNull { it.startsWith("name=") } | ||
| ?.split("'") | ||
| ?.getOrNull(1) |
a8489a8 to
c8ece72
Compare
c8ece72 to
d769712
Compare
No description provided.