Skip to content

Commit

Permalink
Jacoco and Coveralls
Browse files Browse the repository at this point in the history
  • Loading branch information
Binnette committed Nov 21, 2024
1 parent b37cd98 commit c40e170
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 3 deletions.
9 changes: 7 additions & 2 deletions .github/workflows/android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,10 @@ jobs:
- name: Build with Gradle
run: ./gradlew build --stacktrace

- name: Run unit tests
run: ./gradlew testDebugUnitTest --stacktrace
- name: Run unit tests and jacoco coverage
run: ./gradlew testDebugUnitTest jacocoTestReport --stacktrace

- name: Coveralls GitHub Action
uses: coverallsapp/github-action@v2.3.4
with:
format: jacoco
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# OSMTracker for Android™

![Build](https://github.com/labexp/osmtracker-android/actions/workflows/android.yml/badge.svg)
![Build](https://github.com/labexp/osmtracker-android/actions/workflows/android.yml/badge.svg?branch=develop)
[![Coverage Status](https://coveralls.io/repos/github/labexp/osmtracker-android/badge.svg?branch=develop)](https://coveralls.io/github/labexp/osmtracker-android?branch=develop)

**OSMTracker for Android™** is a mobile app designed for OpenStreetMap mappers and outdoor adventurers. It lets you log a GPS track to document your journey. Its customizable buttons let you simply add POIs as track points directly inside your GPX track.

Expand Down
28 changes: 28 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'jacoco'

android {

Expand Down Expand Up @@ -134,3 +135,30 @@ repositories {
mavenCentral()
maven { url "https://jitpack.io" }
}

jacoco {
toolVersion = "0.8.12"
}

tasks.withType(Test) {
jacoco.includeNoLocationClasses = true
jacoco.excludes = ['jdk.internal.*']
}

tasks.register("jacocoTestReport", JacocoReport) {
dependsOn testDebugUnitTest

reports {
xml.required = true
}

def fileFilter = ['**/R.class', '**/R$*.class', '**/BuildConfig.*', '**/Manifest*.*', '**/*Test*.*']
def mainSrc = "${project.projectDir}/src/main/java"

sourceDirectories.setFrom(files([mainSrc]))
classDirectories.setFrom(fileTree(dir: layout.buildDirectory.dir("intermediates/javac/debug").get().asFile, excludes: fileFilter))
executionData.setFrom(fileTree(dir: layout.buildDirectory.get(), includes: [
'jacoco/testDebugUnitTest.exec', 'outputs/unit_test_code_coverage/debugUnitTest/testDebugUnitTest.exec'
]))

}
4 changes: 4 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ buildscript {
}
}

plugins {
id 'jacoco'
}

allprojects {
repositories {
google()
Expand Down

0 comments on commit c40e170

Please sign in to comment.