[#673] process .ec files from emulator.wtf
Co-authored-by: Carter Jernigan <git@carterjernigan.com> Co-authored-by: Honza <rychnovsky.honza@gmail.com>
This commit is contained in:
parent
a450ebec0c
commit
7523619afa
|
@ -0,0 +1,39 @@
|
|||
plugins {
|
||||
id("jacoco")
|
||||
}
|
||||
|
||||
tasks {
|
||||
register("jacocoReport", JacocoReport::class) {
|
||||
group = "Coverage"
|
||||
description = "Generate XML/HTML code coverage reports for coverage.ec"
|
||||
|
||||
reports {
|
||||
xml.required.set(false)
|
||||
html.required.set(true)
|
||||
}
|
||||
|
||||
sourceDirectories.setFrom("${project.projectDir}/src/main/kotlin")
|
||||
val fileFilter =
|
||||
listOf("**/R.class", "**/R$*.class", "**/BuildConfig.*", "**/Manifest*.*", "**/*Test*.*", "android/**/*.*")
|
||||
|
||||
classDirectories.setFrom(
|
||||
files("${buildDir}/intermediates/javac/debug").map {
|
||||
fileTree(it) {
|
||||
exclude(fileFilter)
|
||||
}
|
||||
},
|
||||
files("${buildDir}/tmp/kotlin-classes/debug").map {
|
||||
fileTree(it) {
|
||||
exclude(fileFilter)
|
||||
}
|
||||
})
|
||||
|
||||
executionData.setFrom(
|
||||
files("${buildDir}/test-results").map {
|
||||
fileTree(it) {
|
||||
include("**/*.ec", "**/*.exec")
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
|
@ -4,6 +4,7 @@ plugins {
|
|||
id("secant.android-build-conventions")
|
||||
id("wtf.emulator.gradle")
|
||||
id("secant.emulator-wtf-conventions")
|
||||
id("secant.jacoco-conventions")
|
||||
}
|
||||
|
||||
// Note that we force enable test orchestrator for this module, because some of the test cases require it.
|
||||
|
|
|
@ -2,7 +2,6 @@ plugins {
|
|||
kotlin("multiplatform")
|
||||
id("secant.kotlin-multiplatform-build-conventions")
|
||||
id("secant.dependency-conventions")
|
||||
id("secant.android-build-conventions")
|
||||
}
|
||||
|
||||
kotlin {
|
||||
|
|
|
@ -23,10 +23,18 @@ The app consists of different Gradle module types (e.g. Kotlin Multiplatform, An
|
|||
Kotlin Multiplatform does not support coverage for all platforms. Most of our code lives under commonMain, with a JVM target. This effectively allows generation of coverage reports with Jacoco. Coverage is enabled by default when running `./gradlew check`.
|
||||
|
||||
### Android
|
||||
The Android Gradle plugin supports code coverage with Jacoco. This integration can sometimes be buggy. For that reason, coverage is disabled by default and can be enabled on a case-by-case basis, by passing `-PIS_ANDROID_INSTRUMENTATION_TEST_COVERAGE_ENABLED=true` as a command line argument for Gradle builds. For example: `./gradlew connectedCheck -PIS_ANDROID_INSTRUMENTATION_TEST_COVERAGE_ENABLED=true`.
|
||||
The Android Gradle plugin supports code coverage with Jacoco. This integration can sometimes be buggy. For that reason, coverage is disabled by default and can be enabled on a case-by-case basis, by setting the property `IS_ANDROID_INSTRUMENTATION_TEST_COVERAGE_ENABLED=true`. For example: `./gradlew connectedCheck -PIS_ANDROID_INSTRUMENTATION_TEST_COVERAGE_ENABLED=true`.
|
||||
|
||||
When coverage is enabled, running instrumentation tests will automatically generate coverage reports stored under `$module/build/reports/coverage`.
|
||||
|
||||
### Generating code coverage locally
|
||||
- `./gradlew <android-module-name>:connectedCheck -PIS_ANDROID_INSTRUMENTATION_TEST_COVERAGE_ENABLED=true` for Android modules. These modules internally use JaCoCo to generate test coverage.
|
||||
- `./gradlew <kotlin-only-module-name>:check` for Kotlin modules. These modules internally use Kover to generate test coverage.
|
||||
|
||||
### Generating code coverage with emulator.wtf
|
||||
1. `./gradlew <module-name>:testDebugWithEmulatorWtf -PIS_ANDROID_INSTRUMENTATION_TEST_COVERAGE_ENABLED=true`
|
||||
1. `./gradlew <module-name>:jacocoReport`. The command above only generates `.ec` files, so this separate Gradle task is needed to convert those into a human-readable report.
|
||||
|
||||
## Benchmarking
|
||||
This section provides information about available benchmark tests integrated in this project as well as how to use them. Currently, we support macrobenchmark tests run locally as described in the Android [documentation](https://developer.android.com/topic/performance/benchmarking/benchmarking-overview).
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ plugins {
|
|||
id("secant.android-build-conventions")
|
||||
id("wtf.emulator.gradle")
|
||||
id("secant.emulator-wtf-conventions")
|
||||
id("secant.jacoco-conventions")
|
||||
}
|
||||
|
||||
// Force orchestrator to be used for this module, because we need the preference files
|
||||
|
|
|
@ -4,6 +4,7 @@ plugins {
|
|||
id("secant.android-build-conventions")
|
||||
id("wtf.emulator.gradle")
|
||||
id("secant.emulator-wtf-conventions")
|
||||
id("secant.jacoco-conventions")
|
||||
}
|
||||
|
||||
android {
|
||||
|
|
|
@ -4,6 +4,7 @@ plugins {
|
|||
id("secant.android-build-conventions")
|
||||
id("wtf.emulator.gradle")
|
||||
id("secant.emulator-wtf-conventions")
|
||||
id("secant.jacoco-conventions")
|
||||
}
|
||||
|
||||
android {
|
||||
|
|
|
@ -292,6 +292,7 @@ dependencyResolutionManagement {
|
|||
"androidx-espresso-intents",
|
||||
"androidx-test-core",
|
||||
"androidx-test-junit",
|
||||
"androidx-test-orchestrator",
|
||||
"androidx-test-runner"
|
||||
)
|
||||
)
|
||||
|
|
|
@ -4,6 +4,7 @@ plugins {
|
|||
id("secant.android-build-conventions")
|
||||
id("wtf.emulator.gradle")
|
||||
id("secant.emulator-wtf-conventions")
|
||||
id("secant.jacoco-conventions")
|
||||
}
|
||||
|
||||
android {
|
||||
|
|
|
@ -2,6 +2,7 @@ plugins {
|
|||
id("com.android.library")
|
||||
kotlin("android")
|
||||
id("secant.android-build-conventions")
|
||||
id("secant.jacoco-conventions")
|
||||
}
|
||||
|
||||
android {
|
||||
|
|
|
@ -2,6 +2,7 @@ plugins {
|
|||
id("com.android.library")
|
||||
kotlin("android")
|
||||
id("secant.android-build-conventions")
|
||||
id("secant.jacoco-conventions")
|
||||
}
|
||||
|
||||
android {
|
||||
|
|
|
@ -4,6 +4,7 @@ plugins {
|
|||
id("secant.android-build-conventions")
|
||||
id("wtf.emulator.gradle")
|
||||
id("secant.emulator-wtf-conventions")
|
||||
id("secant.jacoco-conventions")
|
||||
}
|
||||
|
||||
// Force orchestrator to be used for this module, because we need cleared state before each test
|
||||
|
|
|
@ -4,6 +4,7 @@ plugins {
|
|||
id("secant.android-build-conventions")
|
||||
id("wtf.emulator.gradle")
|
||||
id("secant.emulator-wtf-conventions")
|
||||
id("secant.jacoco-conventions")
|
||||
}
|
||||
|
||||
android {
|
||||
|
@ -93,6 +94,7 @@ dependencies {
|
|||
}
|
||||
|
||||
if (project.property("IS_USE_TEST_ORCHESTRATOR").toString().toBoolean()) {
|
||||
androidTestUtil(libs.androidx.test.services)
|
||||
androidTestUtil(libs.androidx.test.orchestrator) {
|
||||
artifact {
|
||||
type = "apk"
|
||||
|
@ -100,3 +102,4 @@ dependencies {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -3,6 +3,10 @@
|
|||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<!-- For test coverage -->
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"
|
||||
android:maxSdkVersion="29"/>
|
||||
|
||||
<application
|
||||
android:icon="@mipmap/ic_launcher_square"
|
||||
android:roundIcon="@mipmap/ic_launcher_round">
|
||||
|
|
Loading…
Reference in New Issue