Skip to content

Commit

Permalink
Merge pull request #162 from appunite/chore/report_test_coverage
Browse files Browse the repository at this point in the history
[LD-139] chore: test coverage report
  • Loading branch information
nowakweronika authored Nov 21, 2023
2 parents 1ecbfbf + 5060651 commit 28846e2
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 3 deletions.
19 changes: 18 additions & 1 deletion .github/workflows/run-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ jobs:
unit-tests:
name: Unit Tests
runs-on: ubuntu-20.04
permissions:
pull-requests: write

steps:
- name: Checkout
Expand All @@ -36,14 +38,29 @@ jobs:
uses: ./.github/actions/prepare-android-env

- name: Run test
run: ./gradlew test
run: ./gradlew codeCoverage
env:
LOUDIUS_CLIENT_SECRET: ${{ secrets.LOUDIUS_CLIENT_SECRET }}
LOUDIUS_CLIENT_ID: ${{ secrets.LOUDIUS_CLIENT_ID }}
LOUDIUS_GITHUB_USER_PASSWORD: ${{ secrets.LOUDIUS_GITHUB_USER_PASSWORD }}
LOUDIUS_GITHUB_USER_NAME: ${{ secrets.LOUDIUS_GITHUB_USER_NAME }}
LOUDIUS_GITHUB_USER_OTP_SECRET: ${{ secrets.LOUDIUS_GITHUB_USER_OTP_SECRET }}

- name: Store HTML coverage report
uses: actions/upload-artifact@v3
with:
name: coverage-report
path: |
*/build/reports/jacoco/codeCoverage/html/**
- name: Add coverage to PR
id: jacoco
uses: madrapps/[email protected]
with:
paths: |
*/build/reports/jacoco/codeCoverage/codeCoverage.xml
token: ${{ secrets.GITHUB_TOKEN }}

- name: Upload tests results
if: always()
uses: actions/upload-artifact@v3
Expand Down
53 changes: 51 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ plugins {
id 'com.android.application'
id 'kotlin-kapt'
id 'org.jetbrains.kotlin.android'
id 'jacoco'
id 'org.jlleitschuh.gradle.ktlint' version '11.6.1'
id 'org.jetbrains.kotlin.plugin.serialization' version '1.9.0'
}
Expand Down Expand Up @@ -43,6 +44,9 @@ android {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
debug{
enableUnitTestCoverage true
}
}
compileOptions {
coreLibraryDesugaringEnabled true
Expand Down Expand Up @@ -89,6 +93,50 @@ android {
}
}

tasks.register('codeCoverage', JacocoReport) {
dependsOn 'testDebugUnitTest'

reports {
html.required.set(true)
xml.required.set(true)
}

classDirectories.setFrom(
fileTree(project.buildDir) {
include("**/tmp/kotlin-classes/debug/**")
exclude(
'**/R.class',
'**/R$*.class',
'**/BuildConfig.*',
"**/*Application.*",
'**/Manifest*.*',
'**/*Test*.*',
'**/android/**/*.*',
'**/androidx/**/*.*',
'**/airbnb/**/*.*',
"**/di/**/*.*",
'**/*Dagger*.*',
"**/*Screen*"
)
}
)

sourceDirectories.setFrom(fileTree(
dir: project.projectDir,
includes: [
"src/main/java/**",
"src/main/kotlin/**"
]))

executionData.setFrom(fileTree(
dir: project.buildDir,
includes: [
"**/*.exec",
"**/*.ec"
]))

}

dependencies {
api project(':components')
//Desugaring for use of java.time in api lower then 26
Expand Down Expand Up @@ -142,11 +190,12 @@ dependencies {
implementation("org.jetbrains.kotlinx:kotlinx-datetime:0.4.1")
testImplementation("org.jetbrains.kotlinx:kotlinx-datetime:0.4.1")


//retrofit & okhttp
implementation 'com.squareup.okhttp3:okhttp:4.11.0'
implementation 'com.squareup.okhttp3:logging-interceptor:4.10.0'



testImplementation project(":app-shared-tests")
androidTestImplementation(project(":app-shared-tests")) {
exclude group: 'org.robolectric', module: 'robolectric'
Expand All @@ -165,4 +214,4 @@ tasks.withType(Test) {

kapt {
correctErrorTypes true
}
}

0 comments on commit 28846e2

Please sign in to comment.