Skip to content

Commit 92cbd32

Browse files
build: integrate Kover test coverage tool at jindong-core (#68)
* build: intergrate Kover test coverage tool * build: generate Kover test coverage report at workflow * Update .github/workflows/gradle.yml Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * Revert "Update .github/workflows/gradle.yml" This reverts commit 5fa08bd. * fix: update test coverage target to jindong-core * fix: configure tests with JUnit platform * test: include androidHostTest scope to properly target JVM source * docs: update README --------- Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
1 parent e8a3f9e commit 92cbd32

6 files changed

Lines changed: 438 additions & 0 deletions

File tree

.github/workflows/gradle.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ on:
1515

1616
permissions:
1717
contents: read
18+
pull-requests: write
1819

1920
jobs:
2021
check:
@@ -59,3 +60,27 @@ jobs:
5960
uses: gradle/gradle-build-action@ce999babab2de1c4b649dc15f0ee67e6246c994f
6061
with:
6162
arguments: allTests
63+
- name: Generate Kover Coverage Report
64+
uses: gradle/gradle-build-action@ce999babab2de1c4b649dc15f0ee67e6246c994f
65+
with:
66+
arguments: :jindong-core:koverXmlReport
67+
- name: Generate Kover HTML Report
68+
uses: gradle/gradle-build-action@ce999babab2de1c4b649dc15f0ee67e6246c994f
69+
with:
70+
arguments: :jindong-core:koverHtmlReport
71+
- name: Upload Coverage Report
72+
uses: actions/upload-artifact@v4
73+
with:
74+
name: coverage-report
75+
path: jindong-core/build/reports/kover/html
76+
- name: Add coverage report to PR
77+
id: kover
78+
if: github.event_name == 'pull_request'
79+
uses: mi-kas/kover-report@v1
80+
with:
81+
path: ${{ github.workspace }}/jindong-core/build/reports/kover/report.xml
82+
token: ${{ secrets.GITHUB_TOKEN }}
83+
title: Jindong Core Test Coverage Report
84+
update-comment: true
85+
min-coverage-overall: 0
86+
min-coverage-changed-files: 0

build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ plugins {
66
alias(libs.plugins.vanniktech.mavenPublish) apply false
77
alias(libs.plugins.spotless) apply false
88
alias(libs.plugins.binaryCompatibilityValidator) apply false
9+
alias(libs.plugins.kover) apply false
910
}
1011

1112
subprojects {

gradle/libs.versions.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ robolectric = "4.16"
1616
androidxTest = "1.7.0"
1717
androidxActivity = "1.12.2"
1818
androidxAnnotation = "1.9.1"
19+
kover = "0.9.4"
1920

2021
[libraries]
2122
kotlin-test = { module = "org.jetbrains.kotlin:kotlin-test", version.ref = "kotlin" }
@@ -24,6 +25,7 @@ kotlinx-coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-c
2425
kotlinx-coroutines-test = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version.ref = "coroutines" }
2526
kotest-framework-engine = { module = "io.kotest:kotest-framework-engine", version.ref = "kotest" }
2627
kotest-assertions-core = { module = "io.kotest:kotest-assertions-core", version.ref = "kotest" }
28+
kotest-runner-junit5 = { module = "io.kotest:kotest-runner-junit5", version.ref = "kotest" }
2729
robolectric = { module = "org.robolectric:robolectric", version.ref = "robolectric" }
2830
androidx-test-core = { module = "androidx.test:core", version.ref = "androidxTest" }
2931
androidx-test-runner = { module = "androidx.test:runner", version.ref = "androidxTest" }
@@ -43,3 +45,4 @@ kotest = { id = "io.kotest", version.ref = "kotest" }
4345
ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" }
4446
android-application = { id = "com.android.application", version.ref = "agp" }
4547
composeMultiplatform = { id = "org.jetbrains.compose", version.ref = "composeMultiplatform" }
48+
kover = { id = "org.jetbrains.kotlinx.kover", version.ref = "kover" }

jindong-core/build.gradle.kts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ plugins {
2222
alias(libs.plugins.kotest)
2323
alias(libs.plugins.ksp)
2424
alias(libs.plugins.binaryCompatibilityValidator)
25+
alias(libs.plugins.kover)
2526
}
2627

2728
apiValidation {
@@ -47,6 +48,10 @@ kotlin {
4748
}
4849
}
4950
}
51+
52+
withHostTest {
53+
isIncludeAndroidResources = true
54+
}
5055
}
5156
iosX64()
5257
iosArm64()
@@ -65,6 +70,15 @@ kotlin {
6570
implementation(libs.kotest.framework.engine)
6671
implementation(libs.kotest.assertions.core)
6772
}
73+
74+
named("androidHostTest").dependencies {
75+
implementation(libs.robolectric)
76+
implementation(libs.androidx.test.core)
77+
implementation(libs.androidx.test.runner)
78+
implementation(libs.kotest.assertions.core)
79+
implementation(libs.kotlinx.coroutines.test)
80+
implementation(libs.kotest.runner.junit5)
81+
}
6882
}
6983
}
7084

@@ -103,3 +117,20 @@ mavenPublishing {
103117
}
104118
}
105119
}
120+
121+
tasks.withType<Test>().configureEach {
122+
useJUnitPlatform()
123+
}
124+
125+
kover {
126+
reports {
127+
total {
128+
html {
129+
onCheck = true
130+
}
131+
xml {
132+
onCheck = true
133+
}
134+
}
135+
}
136+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Android Host Tests
2+
3+
Robolectric-based Android tests that run on JVM without requiring an emulator.
4+
5+
## Running Tests
6+
7+
```bash
8+
# Run Android host tests only
9+
./gradlew :jindong-core:testAndroidHostTest
10+
11+
# Run all tests (including commonTest, iosTest, etc.)
12+
./gradlew :jindong-core:allTests
13+
```
14+
15+
> **Note**: Use `--rerun-tasks` when you need to re-run tests that Gradle considers up-to-date (e.g., after changing test configuration or debugging flaky tests).
16+
17+
## Test Scenarios
18+
19+
To be updated...
20+
21+
| Category | Test | Jindong Mapping |
22+
|----------|------|-----------------|
23+
| **OneShot** | High intensity (255) | `HapticIntensity.HIGH` |
24+
| | Medium intensity (128) | `HapticIntensity.MEDIUM` |
25+
| | Low intensity (64) | `HapticIntensity.LIGHT` |
26+
| **Waveform** | Simple sequence | `Sequence { Haptic, Delay, Haptic }` |
27+
| | Complex sequence | `Repeat { Haptic, Delay }` |
28+
| **Edge Cases** | Minimum duration (1ms) | - |
29+
| | Minimum amplitude (1) | - |
30+
| **Control** | Cancel | `executor.cancel()` |
31+
32+
33+
## Configuration
34+
35+
- **SDK**: API 26 (Android 8.0)
36+
- **Runner**: `RobolectricTestRunner`

0 commit comments

Comments
 (0)