Skip to content

Commit

Permalink
Add Codecov code coverage (#1)
Browse files Browse the repository at this point in the history
* Jacoco working, but failing tests due to reflection
* Fix code coverage by ignoring synthetic members

jacoco code coverage was failing due to detecting synthetic members.
This was apparently bad practice as detailed
[here](https://groups.google.com/forum/?utm_medium=email&utm_source=footer#!msg/jacoco/3wT1WmrRPBA/WgtY21EKHQAJ)
  • Loading branch information
snowe2010 committed Feb 12, 2019
1 parent 239af91 commit df8b582
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 32 deletions.
37 changes: 22 additions & 15 deletions .travis.yml
@@ -1,27 +1,34 @@
language: java
install: true

after_success:
- bash <(curl -s https://codecov.io/bash)

before_cache:
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
- rm -fr $HOME/.gradle/caches/*/plugin-resolution/
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
- rm -fr $HOME/.gradle/caches/*/plugin-resolution/

cache:
directories:
- "$HOME/.gradle/caches/"
- "$HOME/.gradle/wrapper/"
- "$HOME/.gradle/caches/"
- "$HOME/.gradle/wrapper/"
before_install:
- chmod +x gradlew
- chmod +x gradlew

stages:
- name: build
- name: release
if: tag IS present
- name: build
- name: release
if: tag IS present

jobs:
include:
- stage: build
script:
- "./gradlew build --scan -s"
- stage: release
script:
- "./gradlew -Prelease.useLastTag=true final --info --stacktrace"
secure: vWij4zhptWiQqJ06IYHu04Mow5ODf6JowPFtTDu8uGCxt9L3AhEnjWdNvrhKOSx3jSYIGrK+jVGzGm2Y/73W7DJCEroFrLzUqmONY2hRnC60n6m56d29ymmwdsP+ffgujwmHd56LDMIT5tT+o4X1Bu1c6uYZpuvR0KSNxjbQjYpaq4mKx8fwd6WEFQz9N1RThtvtBbkXUJ4yCXgt5MDSUaHKGE4VC9tIDQB3oibm1RVeVM9YURenigbpL54V7U0A2edOgrOB9uFnp8fqVJ+Jugc6tFSVDTAPMczs20TtZPU5CeXc5Bo5Fk0tRrU8uhpsraLCoPPQgtUnlRYY3TD8HyWtVXEohhvIM48i4u+VC4twsD0T2MbGwiGKbaE1KWu1gwzx12nbjQqFqfEF6RyTkHQXmFFENeRiHP50dzrLXwyOgMv2iUan8ffuXImysIPHTLMyQ47GFxznpX5vfbu44RCQLCZQwvQo0/Zq3LUzQ1VPUAA+1WikdVqvbyKm+51vTVhn7aqVt1WdmddAhcQMH3rQM+3ryA4vuWzmfsge+gxufhBdb2j37J32iGc8T6/hCG7HKn7Afia8uEjEJBRpMQpk1mTDuCRJ4RoTIrF1oqDeV8yGsebdTMdGFJsVUCa1bk139A0V3qW4ys7hIBm8ZRuo5JI/59hKZSdBGjsKnbI=
- stage: build
script:
- "./gradlew build --scan -s"
- stage: release
script:
- "./gradlew -Prelease.useLastTag=true final --info --stacktrace"

env:
global:
secure: DsBw6sx7/16MmjLtmWrLGRmh3oVXC69F5xteb7oXF8uGY7p70u1WJK55N/UU5thKC06r/Q/5CzCvpYIQx3N9U3BnIt2MOpXiNoW7BcsRmhxgGn2inVDVeBFCz9YMASnGeMuSTg2EH3d25d9kxrRqyZCw3juOz+MVn5kHkHoTd1MKZFhwp9gosWfJDLuCV+cCp5fyizlmbNXnMubUDKxsluBEYoEue1yI3OMvoRZp8Kqu0EUk7Zn+FIG9F5SHLpWPn7YQS1coVrMPIvv7IaQpw4Jh+jNS4xL39yiD/M/ZaD0cln5B0uHlxJjb1bI+I9B9rtli8SJPKQKbo7ZB1oG9n+AeipBnON0N8DHUbS833mYV0lSio27rD9Ze9xpMTY9n3VhI1SrBzKYXs5w/iUWmdWPc2IXMreluq5cbr4d5+9Hg/sjFth5nk5bhW1N5TVYNO85ZM9Of9jTjJGxLAMt4eFYb4D6zyG5dBlYW3jbVF2Y+Za7oHb+UY/IJKb1qW93EZsGLKatZpwxV2/w0KqekeLIz0ABffIANL4k7J1k1uD5N4ugShDM65NDpVvHLZXc2kocVHF0AYddjy/BLJCnnInh0+YMrhWrkUSbl1YyXDADrud/nePE/MHQG0acYzCoe2IaME2o/ADvWSMl0Qi2rlQ0AfWdDQjL3arfAj6Ea2Ao=
46 changes: 30 additions & 16 deletions build.gradle.kts
@@ -1,8 +1,8 @@
import com.jfrog.bintray.gradle.BintrayExtension
import org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestFramework
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

val kotlin_version = "1.3.11"
val spek_version = "2.0.0-alpha.2"
val spekVersion = "2.0.0-alpha.2"

plugins {
`build-scan`
Expand All @@ -12,8 +12,8 @@ plugins {
id("nebula.source-jar") version "9.4.6"
id("nebula.release") version "9.2.0"
id("nebula.nebula-bintray-publishing") version "5.0.0"
jacoco
}

group = "com.tylerthrailkill.helpers"

repositories {
Expand All @@ -23,26 +23,26 @@ repositories {
}

dependencies {
compile(kotlin("stdlib-jdk8"))
compile(kotlin("reflect"))
testCompile(kotlin("test"))
testCompile(kotlin("test-junit"))
implementation(kotlin("stdlib-jdk8"))
implementation(kotlin("reflect"))
testImplementation(kotlin("test"))
testImplementation(kotlin("test-junit"))

// logging
implementation(group = "ch.qos.logback", name = "logback-classic", version = "1.3.0-alpha4")
implementation(group = "org.slf4j", name = "slf4j-simple", version = "1.6.1")
implementation("io.github.microutils:kotlin-logging:1.6.22")

compile(group = "ch.qos.logback", name = "logback-classic", version = "1.3.0-alpha4")
compile(group = "org.slf4j", name = "slf4j-simple", version = "1.6.1")
compile("io.github.microutils:kotlin-logging:1.6.22")
testImplementation("com.nhaarman.mockitokotlin2:mockito-kotlin:2.1.0")
testImplementation("io.mockk:mockk:1.9.kotlin12")
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version")

testImplementation("org.spekframework.spek2:spek-dsl-jvm:$spek_version") {
testImplementation("org.spekframework.spek2:spek-dsl-jvm:$spekVersion") {
exclude(group = "org.jetbrains.kotlin")
}
testRuntimeOnly("org.spekframework.spek2:spek-runner-junit5:$spek_version") {
testRuntimeOnly("org.spekframework.spek2:spek-runner-junit5:$spekVersion") {
exclude(group = "org.junit.platform")
exclude(group = "org.jetbrains.kotlin")
}
testImplementation("com.beust:klaxon:5.0.1")
testImplementation("com.beust:klaxon:5.0.1") // used to parse naughty list
testImplementation(group = "org.junit.platform", name = "junit-platform-engine", version = "1.3.0-RC1")
}

Expand All @@ -52,14 +52,28 @@ tasks {
}

withType<Wrapper> {
gradleVersion = "4.10.2"
distributionType = Wrapper.DistributionType.ALL
}

withType<Test> {
useJUnitPlatform {
includeEngines("spek2")
}
}
val report = withType<JacocoReport> {
reports {
xml.apply {
isEnabled = true
this.destination = file("$buildDir/jacoco/report.xml")
}
html.apply {
isEnabled = true
this.destination = file("$buildDir/jacoco/html_report")
}
}
dependsOn("test")
}
this["check"].dependsOn(report)
}

buildScan {
Expand Down
Expand Up @@ -39,7 +39,7 @@ private fun recurse(obj: Any?, currentDepth: String = "") {
val className = "${obj?.javaClass?.simpleName}("
write(className)

obj?.javaClass?.declaredFields?.forEach {
obj?.javaClass?.declaredFields?.filter { !it.isSynthetic }?.forEach {
val pad = deepen(currentDepth)
it.isAccessible = true
PRINT_STREAM.println()
Expand Down

0 comments on commit df8b582

Please sign in to comment.