带有gradle和kotlin的Jacoco没有创建jacoco.exec文件

时间:2017-11-26 21:01:14

标签: gradle kotlin jacoco

我已经设置了一个基本的kotlin项目(空类,一个测试文件),并尝试使用gradle插件设置jacoco with gradle:https://docs.gradle.org/current/userguide/jacoco_plugin.html

当我运行测试时,一个测试通过,但是没有创建jacoco.exec文件。我错过了什么?我假设这些类永远不会得到检测,但似乎无法找到有关如何为jacoco设置build.gradle的更多信息。或者jacoco可以不是从kotlin创建的类文件吗?

group 'com.ronnev.filewatcher'
version '0.1'

buildscript {
    ext.kotlin_version = '1.1.61'

    repositories {
        mavenCentral()
    }
    dependencies {
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath 'org.junit.platform:junit-platform-gradle-plugin:1.0.2'
    }
}

apply plugin: 'kotlin'
apply plugin: 'org.junit.platform.gradle.plugin'
apply plugin: 'jacoco'

repositories {
    mavenCentral()
    jcenter()
}

dependencies {
    compile "org.jetbrains.kotlin:kotlin-stdlib-jre8:$kotlin_version"

    testCompile 'org.junit.jupiter:junit-jupiter-api:5.0.2'

    testRuntime 'org.junit.jupiter:junit-jupiter-engine:5.0.2'
}

jacoco {
    toolVersion = "0.7.9"
    reportsDir = file("$buildDir/jacoco/")
}

jacocoTestReport {
    classDirectories = files("${buildDir}/classes")

    reports {
        xml.enabled true
        csv.enabled false
        html.destination file("${buildDir}/jacoco/jacocoHtml")
    }
}

test {
    jacoco {
        append = false
        destinationFile = file("$buildDir/jacoco/jacocoTest.exec")
    }
}

当我运行gradle测试时,我希望创建一个build / jacoco / jacoco.exec文件但不是。

vextorspace@vPrecise:~/projects/filewatcher $ gradle clean test
:clean
:compileKotlin
w: /home/vextorspace/projects/filewatcher/src/main/kotlin/com/ronnev/filewatcher/files/DependentFinder.kt: (6, 28): Parameter 'className' is never used
:compileJava UP-TO-DATE
:copyMainKotlinClasses
:processResources UP-TO-DATE
:classes UP-TO-DATE
:compileTestKotlin
:compileTestJava UP-TO-DATE
:copyTestKotlinClasses
:processTestResources
:testClasses
:junitPlatformTest

Test run finished after 71 ms
[         2 containers found      ]
[         0 containers skipped    ]
[         2 containers started    ]
[         0 containers aborted    ]
[         2 containers successful ]
[         0 containers failed     ]
[         1 tests found           ]
[         0 tests skipped         ]
[         1 tests started         ]
[         0 tests aborted         ]
[         1 tests successful      ]
[         0 tests failed          ]

:test SKIPPED

BUILD SUCCESSFUL

当我查看构建目录时,没有创建jacoco文件夹:

vextorspace@vPrecise:~/projects/filewatcher $ ls build
classes  kotlin  kotlin-build  kotlin-classes  resources  test-results

非常感谢任何帮助或提示!

谢谢!

0 个答案:

没有答案