如何为一个 .jar 文件生成 Jacoco 测试报告?

huangapple 未分类评论62阅读模式
英文:

How to generate Jacoco test report for a .jar file?

问题

以下是您提供的内容的翻译:

我对Gradle非常陌生。
我已经编写了测试套件。然而,

jacoco报告没有显示来自.jar文件的任何类

如何为一个 .jar 文件生成 Jacoco 测试报告?

通过以下设置,jacoco在普通的java文件上运行得很好。

这是我的build.gradle:

plugins {
    id 'java'
    id 'jacoco'
}

version '1.0-SNAPSHOT'

sourceCompatibility = 1.8

repositories {
    mavenCentral()
}

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

dependencies {
    testCompile group: 'junit', name: 'junit', version: '4.12'
    testCompile 'org.hamcrest:hamcrest-all:1.3'
    compile files('libs/PACV1.jar') //这是我放置jar文件的位置
}

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

jacocoTestReport.dependsOn test

如果您需要更多帮助,请随时提问。

英文:

I'm very new to Gradle.
I have written the test suites. However,

jacoco report doesn't show any classes from .jar file

如何为一个 .jar 文件生成 Jacoco 测试报告?

With this setting below, jacoco runs very well with normal java files.

This is my build.gradle:

plugins {
    id 'java'
    id 'jacoco'
}

version '1.0-SNAPSHOT'

sourceCompatibility = 1.8

repositories {
    mavenCentral()
}

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

dependencies {
    testCompile group: 'junit', name: 'junit', version: '4.12'
    testCompile 'org.hamcrest:hamcrest-all:1.3'
    compile files('libs/PACV1.jar') //this is where I put the jar file
}

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

jacocoTestReport.dependsOn test

huangapple
  • 本文由 发表于 2020年3月15日 09:08:38
  • 转载请务必保留本文链接:https://java.coder-hub.com/60688829.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定