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

Add coverage report #148

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions composer/src/main/kotlin/com/gojuno/composer/Consts.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.gojuno.composer

val EXTERNAL_STORAGE = "/storage/emulated/0"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I meant retrieving the actual value from environment on device using something like adb shell printenv EXTERNAL_STORAGE.
AFAIR it is mandatory: https://source.android.com/devices/storage/config-example

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Btw I guess we can have this code in commander

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you need me to try and do this or will you add something more generic to commander ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll add it to commander now

val COVERAGE_DIR = "$EXTERNAL_STORAGE/app_coverage"
val SCREENSHOTS_DIR = "$EXTERNAL_STORAGE/app_spoon-screenshots"
2 changes: 1 addition & 1 deletion composer/src/main/kotlin/com/gojuno/composer/Main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ private fun runAllTests(args: Args, testPackage: TestPackage.Valid, testRunner:
val installTimeout = Pair(args.installTimeoutSeconds, TimeUnit.SECONDS)
val installAppApk = device.installApk(pathToApk = args.appApkPath, timeout = installTimeout)
val installTestApk = device.installApk(pathToApk = args.testApkPath, timeout = installTimeout)
val coverageDir = "/storage/emulated/0/app_coverage/${testPackage.value}"
val coverageDir = "$COVERAGE_DIR/${testPackage.value}"
val makeCoverageDir = if (args.coverage) {
process(commandAndArgs = listOf(adb, "-s", device.id, "shell", "mkdir", "-p", coverageDir))
.map { Unit }
Expand Down
4 changes: 2 additions & 2 deletions composer/src/main/kotlin/com/gojuno/composer/TestRun.kt
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ fun AdbDevice.runTests(
if (coverage) {
coverageReportDir.mkdirs()
adbDevice.pullFolder(
folderOnDevice = "/storage/emulated/0/app_coverage/$testPackageName/coverage.ec",
folderOnDevice = "$COVERAGE_DIR/$testPackageName/coverage.ec",
folderOnHostMachine = coverageReport,
logErrors = verboseOutput
).map { coverageReport }
Expand Down Expand Up @@ -183,7 +183,7 @@ private fun pullTestFiles(adbDevice: AdbDevice, test: InstrumentationTest, outpu
adbDevice
.pullFolder(
// TODO: Add support for internal storage and external storage strategies.
folderOnDevice = "/storage/emulated/0/app_spoon-screenshots/${test.className}/${test.testName}",
folderOnDevice = "$SCREENSHOTS_DIR/${test.className}/${test.testName}",
folderOnHostMachine = screenshotsFolderOnHostMachine,
logErrors = verboseOutput
)
Expand Down