Skip to content

Commit 8a2d4f8

Browse files
committed
Fix coverage report
1 parent ac3f9c4 commit 8a2d4f8

File tree

3 files changed

+36
-3
lines changed

3 files changed

+36
-3
lines changed

.github/workflows/buid.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,12 @@ jobs:
2121
java-version: 17
2222

2323
- name: Build and Test coverage Report
24-
run: bash ./gradlew test jacocoTestReport --stacktrace
24+
run: bash ./gradlew test unitTestCoverageReport --stacktrace
2525

2626
- uses: codecov/codecov-action@v5.1.2
27+
with:
28+
files: ./app/build/reports/jacoco/unitTestCoverageReport/unitTestCoverageReport.xml,./securesmsproxyapi/build/reports/jacoco/unitTestCoverageReport/unitTestCoverageReport.xml
29+
token: ${{ secrets.CODECOV_TOKEN }}
2730

2831
apk:
2932
name: Generate APK

app/build.gradle

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,19 @@ int vcode = Integer.parseInt((versionProps['VERSION_CODE'] == null || versionPro
1313
String vname = (versionProps['VERSION_NAME'] == null || versionProps['VERSION_NAME'].startsWith('$')) ? '3.5.0-dev' : versionProps['VERSION_NAME']
1414

1515
jacoco {
16-
toolVersion = "0.8.7"
16+
toolVersion = "0.8.12"
17+
}
18+
19+
tasks.register("unitTestCoverageReport", JacocoReport) {
20+
group = "Coverage"
21+
dependsOn tasks.testDebugUnitTest
22+
reports {
23+
html.required = true
24+
xml.required = true
25+
}
26+
executionData.from = layout.buildDirectory.dir("outputs/unit_test_code_coverage/debugUnitTest/testDebugUnitTest.exec")
27+
classDirectories.from = layout.buildDirectory.dir("intermediates/javac/debug/compileDebugJavaWithJavac/classes")
28+
sourceDirectories.from = layout.projectDirectory.dir("src/main/java")
1729
}
1830

1931
android {
@@ -27,6 +39,9 @@ android {
2739
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
2840
}
2941
buildTypes {
42+
debug {
43+
enableUnitTestCoverage true
44+
}
3045
release {
3146
minifyEnabled false
3247
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'

securesmsproxyapi/build.gradle

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,19 @@ ext["ossUsername"] = System.getenv('OSS_USERNAME')
2626
ext["ossPassword"] = System.getenv('OSS_PASSWORD')
2727

2828
jacoco {
29-
toolVersion = "0.8.7"
29+
toolVersion = "0.8.12"
30+
}
31+
32+
tasks.register("unitTestCoverageReport", JacocoReport) {
33+
group = "Coverage"
34+
dependsOn tasks.testDebugUnitTest
35+
reports {
36+
html.required = true
37+
xml.required = true
38+
}
39+
executionData.from = layout.buildDirectory.dir("outputs/unit_test_code_coverage/debugUnitTest/testDebugUnitTest.exec")
40+
classDirectories.from = layout.buildDirectory.dir("intermediates/javac/debug/compileDebugJavaWithJavac/classes")
41+
sourceDirectories.from = layout.projectDirectory.dir("src/main/java")
3042
}
3143

3244
android {
@@ -43,6 +55,9 @@ android {
4355
}
4456

4557
buildTypes {
58+
debug {
59+
enableUnitTestCoverage true
60+
}
4661
release {
4762
minifyEnabled false
4863
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'

0 commit comments

Comments
 (0)