Jacoco单元和集成测试覆盖 - 个人和整体 [英] Jacoco Unit and Integration Tests coverage - individual and overall

查看:141
本文介绍了Jacoco单元和集成测试覆盖 - 个人和整体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个项目(ProjectA),其中包含一些单元测试和集成测试。



以下是结构。



ProjectA
- src / java(java源代码)

- test / java(Junit单元测试)

- test / resources(需要资源对于Junit单元测试)
- src / java-test(集成测试)

- conf(包含构建/测试/编译所需的.xml文件) >



我运行以下命令 - 它们都可以工作,但是我对build.gradle / GRADLE_HOME / init.d / * .gradle文件正在影响我所得到的。



这似乎是我错过了一些东西,并没有得到我想要的东西。



命令

- gradle clean build - 它可以正常工作
- gradle clean build jacocoTestReport - 工作正常。

- gradle clean build integrationTest jacocoTestReport - 它工作正常(如果我有一个tomcat实例在另一个putty窗口中运行,并且运行在同一个ProjectA中)。



第三个项目符号操作后完成后,我在Jenkins作业工作区中看到额外的文件夹build及其子文件夹(除了从源代码/版本控制中检出的东西)。



即under - JenkinsWorkspace

/ build

- (包含以下提及的.class文件其中一个sourceSets部分)

---- integrationTest

---- main

---- test <
- 资源(包含源代码管理中conf文件夹下的所有文件.properties / .xml文件。)
- 报告(包含针对PMD / CheckStyle / Findbugs的.xml / .html文件以及针对Unit或IT Tests的测试结果,但不包括两者)
---- checkstyle >
---- findbugs

---- pmd

---- jacoco

---- tests(
注意:这是复数形式,即它不是测试,它被定义为sourceSets中的一个条目)
jacoco 包含2个.exec文件,即test.exec和integrationTest.exec文件大小不同)
---- test.exec

---- integrationTest.exec < BR / >
- jacocoHtml (该文件夹包含大量文件夹(包含.html文件),并且主要包含index.html。

- --- somexxxfolders

---- ---- somexxfolder's.html文件

---- index.html


--- - 其他etc文件/文件夹
测试结果(这包含一些.xml文件,但仅适用于单元测试或集成测试 - 但不是)。


也就是说,如果我运行gradle clean build,你会看到单元测试相关的.xml文件和
,如果我运行gradle clean build integrationTest,则单元测试.xml文件被覆盖
,我看到的.xml文件只与integrationTest任务相关/生成。





以下是常用gradle(GRADLE_HOME / init.d / some.common.gradle文件)之一

  // 
//额外的文件可以保存全局的Gradle设置,这样它们就不必是inse在项目
//特定的build.gradle文件中进行。
//文件名:extraN.common< anyname> .gradle
allprojects {
apply plugin:'java'
apply plugin:'pmd'
apply plugin:' findbugs'
apply plugin:'checkstyle'
apply plugin:'jacoco'
apply plugin:'sonar-runner'
tasks.withType(Compile){
options .debug = true
options.compilerArgs = [-g]
}
sourceSets {
main {
java {
// MOTE:If你的项目的build.gradle指定sourceSet部分,下面的
//值将被什么项目的build.gradle设置覆盖。
//
//如果项目的sourceSet结构在每个项目中不同,那么在此
//全局公共.gradle文件中,可以为主或其他部分(如$ b)定义srcDir $ b // test,integrationTest等如下所示 - 注释掉。如果是这样的话,
//然后取消注释下面的行,并使用// - srcDir的'src / java'行
// for sourceSets.main.java部分注释掉。该规则也适用于其他部分。
// srcDir'no_src_dir_set_yet'

srcDir'src / java'
}
资源{
srcDir'conf'
}

测试{
java {
srcDir'test / java'
}
资源{
srcDir'test / resources'
srcDir'conf'
}
}
integrationTest {
java {
srcDir'src / java-test'
}
resources {$
sonarRunner {
sonarProperties {

}
属性sonar.host.url,http:// $ sonarServerUrl:9000
属性sonar.jdbc.url,jdbc:h2:tcp:// $ sonarServerUrl:9092 /声纳
属性sonar.jdbc.driverClassName,org.h2.Driver
属性sona r.jdbc.username,sonar
属性sonar.jdbc.password,sonar
properties [sonar.sources] + = sourceSets.main.allSource.srcDirs
// properties [sonar.tests] + = sourceSets.test.java.srcDirs
properties [sonar.tests] + = sourceSets.integrationTest.allSource.srcDirs
}
}
checkstyle {
configFile = new File(rootDir,config / checkstyle.xml)
ignoreFailures = true
// sourceSets = [sourceSets.main,sourceSets.test, sourceSets.integrationTest]
sourceSets = [sourceSets.main]
}
findbugs {
ignoreFailures = true
sourceSets = [sourceSets.main]
}
pmd {
ruleSets = [basic,braces,design]
ignoreFailures = true
}
jacoco {
toolVersion =0.6 .2.201302030002
reportsDir = file($ buildDir / customJacocoReportDir)
}
task testReport(t ype:TestReport){
destinationDir = file($ buildDir / reports / allTests)
}
test {
jacoco {
// destinationFile = file( $ buildDir / jacocoTest.exec)
destinationFile = file($ buildDir / jacoco / test.exec)
// classDumpFile = file($ buildDir / jacoco / classpathdumps)
classDumpFile = file($ buildDir / build / classes / test)
}
}
jacocoTestReport {
group =Reporting
description =Generate Jacoco在运行测试后报道了报道。
reports {
xml {
已启用true
destination$ {buildDir} /reports/jacoco/jacoco.xml
}
csv.enabled false
html {
enabled true
destination$ {buildDir} / jacocoHtml
}
}
additionalSourceDirs = files(sourceSets.main.allJava.srcDirs )
// additionalSourceDirs = files([sourceSets.main.allJava.srcDirs,xxxx,'xxxxyyyy'])
}
}



build.gradle 文件看起来像:

  import com.tr.ids.gradle.CustomFileUtil 
apply plugin:'CustomSetup'
apply plugin:'java'
apply plugin:'customJarService'
apply plugin :'customWarService'
sourceSets {
main {
java {
srcDir'src / java'
}
}
测试{
java {
srcDir'test / java'
}
资源{
srcDir'test / resources'
srcDir'conf'
}
}
integrationTest {
java {
srcDir'src / java-test'
}
}
}
//从外部文件读取依赖列表。我们的自定义插件为编译/测试/战争相关的.jar文件条目读取dep-xxx.txt文件
//其中每个条目类似于:groupid:artifactid:xxx
//这些工件jar是可用于Artifactory
列表depListCompile = customFileUtil.readIntoList($ projectDir / dep-compile.txt)
List depListTest = customFileUtil.readIntoList($ projectDir / dep-testArtifacts.txt)
列表depListWar = customFileUtil.readIntoList($ projectDir / dep-war.txt)
//定义依赖关系
依赖关系{
//编译
编译depListCompile
//单元测试
testCompile depListTest
//集成测试
//编译和测试编译目标的所有内容
integrationTestCompile configurations.compile
integrationTestCompile configurations.testCompile
//编译main文件的输出
integrationTestCompile sourceSets.main.output
//战争和其他人的附加依赖关系
integrationTe stCompile depListTest,depListWar
//所有配置文件
integrationTestRuntime文件('conf')
}
任务deployTomcat(类型:Copy,dependsOn:[jar,compileIntegrationTestJava,warService]) {
从$ buildDir / customWar / $ {project.name} .war
到$ projectDir / tomcat / webapps
}
build {
dependsOn deployTomcat

任务integrationTest(类型:Test,dependsOn:cleanTest){
jacoco {
// destinationFile = file($ buildDir / jacoco / jacocoTest.exec)
destinationFile = file($ buildDir / jacoco / integrationTest.exec)
// classDumpFile = file($ buildDir / jacoco / classpathdumps)
classDumpFile = file($ buildDir / classes / integrationTest)
}
testClassesDir = sourceSets.integrationTest.output.classesDir
classpath = sourceSets.integrationTest.runtimeClasspath
}
apply plugin:'eclipse'
eclipse.classpath {
//定义Eclipse的输出目录不会意外地将clobber / bin
defaultOutputDir = file('out / classes')
//添加集成测试
plusConfigurations + = configurations.integrationTestCompile
//删除不必要的文件
file.whenMerged {classpath - >
classpath.entries.removeAll {entry - > (entry.path.indexOf('/ build / classes / main')> 0)}
classpath.entries.removeAll {entry - > (entry.path.indexOf('/ build / resources / main')> 0)}
}
}

我的问题

1)为什么gradle clean build integrationTest测试结果在build / reports / tests和build / test-results文件夹中。

对于jacoco的测试和build.gradle for integrationTest任务,它总是创建test.exec和integrationTest.exec文件,但生成的build / jacocoHtml文件夹index.html文件不显示与单元/集成测试相关的coverage /文件。为了证明这一点,如果我运行gradle clean build integrationTest jacocoTestReport sonarRunner,我会看到作业的工作区,现在包含.sonar文件夹和build / reports / sonar文件夹,其中包含另一个名为overall-xxx.exec的文件一些文件,但该文件大小并不接近Unit test.exec和IT integrationTest.exec文件大小的总和。尽管它比test.exec文件大小还要小几个字节。3)我可以设置什么样的配置来覆盖单元测试和IT测试,也就是整体测试。 exec文件获得好的大小(在运行sonarRunner任务后)。在SonarRunner任务期间,我确实看到SonarRunner任务的jacocoSensor步骤确实同时看到UT和IT .exec文件以及整个.exec文件,并且自动地(Sonar的一个很好的功能)。

解决方案

找到第二个问题的答案。高级信息:


  1. Gradle 1.6 jacocoTestReport使用不同的变量,Gradle> = 1.7使用不同的变量。 b

    例如,我们可以通过使用CORRECT变量更改test或integrationTest任务来调整单元测试和集成测试.exec文件创建 - 否则它不会工作n生成test.exec和integrationTest.exec默认文件名。见下面的例子。

  2. {...}节可以为我们正在使用的Gradle版本提供正确的变量。



    pre $ task integrationTest(type:测试){
    testClassesDir = sourceSets.integrationTest.output.classesDir

    classpath = sourceSets.integrationTest.runtimeClasspath

    testReportDir = file($ buildDir / reports / tests / IT)
    testResultsDir =文件($ buildDir / test-results / IT)



    ignoreFailures = true
    jacoco {

    //这适用于1.6
    destPath = file($ buildDir / jacoco / IT / jacocoIT.exec)
    classDumpPath = file($ buildDir / jacoco / IT / classpathdumps )
    $ b $ * / $
    以下版本只适用于版本> = 1.7版本的Gradle
    destinationFile = file($ buildDir / jacoco / IT / jacocoIT.exec)
    classDumpFile = file($ buildDir / jacoco / IT / classpathdumps)
    * /
    }
    }

    同样,对于测试{....}任务,您可以将其定义为../../UT/jacocoUT.exec和。 ./../ UT / classpathdumps ...


    1. .sonar文件夹被创建,如果我运行sonar-runnerLinux / Unix sonar-runner可执行文件在我的项目工作区中,但是如果我运行调用Gradleclean build integrationTest jacocoTestReport sonarRunner的Jenkins作业,那么会创建build / sonar文件夹并成为SONAR的WORKING DIR(在输出期间显示) 。在Jenkins的Post build部分下,我提到了下面这个,现在,Jenac Dashboard上的jacoco代码覆盖率报告分别为jacoco文件(.html和.html)。 xml) - 包含单元和集成测试代码覆盖数据。



    2. 我提到:



      执行文件的路径: / build / jacoco / UT / jacocoUT .exec,* /build/jacoco/IT/jacocoIT.exec
      路径t o class dirs:*
      / build / jacoco /
      / classpathdumps / com / thc
      (这是Jacoco插装类的位置)。build / jacoco / UT / classpathdumps / com / thc和build / jacoco / IT / classpathdumps / com / thc将被选为**将替换为build / jacoco下的任何文件夹。这个值也可以设置为build / classes文件夹。


      源文件的路径:**
      (如果我使用src / java,源文件的链接很少不起作用, t显示)..使用** ..它现在有效。

      休息框 - 留空。


      1. 还在想 - 为什么overall-jacoco.exec没有文件大小= jacocoUT.exec和jacocoIT.exec的总和

      此时,我可以看到Jacoco代码覆盖了单元和集成测试,即通过访问作业仪表板上的Jacoco代码覆盖图像并访问源代码链接,并且如果您浏览并浏览 build / reports / jacoco / html / index.html或build / jacocoHtml / index.html文件。

      仍在尝试找出 - 需要做什么为SONAR选择这2个.exec文件(我为sonar.xxx variurs变量设置了有效值,用于UT / IT EXEC文件的源代码,测试,二进制文件,... reportsPath等...在SonarQube仪表板上,单元测试覆盖率为显示f但是整合测试的覆盖率仍然是0.0%。



      我将很快粘贴我的common.gradle和项目的build.gradle文件的副本。更好看。


      I have a project (ProjectA) which contains some unit tests and integration tests.

      Following is the structure.

      ProjectA - src/java (java source code)
      - test/java (Junit unit tests)
      - test/resources (resources required for Junit Unit tests)
      - src/java-test (Integration tests)
      - conf (contains .xml files required for building/testing/compiling purposes)

      I run the following commands -- All of them works but I have a doubt on how the configurations that I have in build.gradle / GRADLE_HOME/init.d/*.gradle files are affecting what I'm getting.

      It seems like I'm missing something and not getting where I want what.

      Commands:
      - gradle clean build -- it works fine
      - gradle clean build jacocoTestReport -- it works fine.
      - gradle clean build integrationTest jacocoTestReport -- it works fine (if I have a tomcat instance up and running in another putty window for the same ProjectA).

      After the 3rd bullet operation is complete, I see the extra folder "build" and its subfolders (other than what's checked out from source/version control) in my Jenkins jobs workspace.

      i.e. under -- JenkinsWorkspace
      /build
      - classes (contains .class files for the following which are mentioned as one of the sourceSets section)
      ---- integrationTest
      ---- main
      ---- test

      - resources (this contains all the files .properties/.xml files which were under "conf" folder in source control.

      - reports (contains .xml/.html files for PMD/CheckStyle/Findbugs and Tests results for either Unit or IT Tests but NOT both). ---- checkstyle
      ---- findbugs
      ---- pmd
      ---- jacoco
      ---- tests (Note: this is plural i.e. it's not "test" which is defined as one entry in sourceSets)

      - jacoco (This contains 2 .exec files i.e. test.exec and integrationTest.exec both have different file size)
      ---- test.exec
      ---- integrationTest.exec

      - jacocoHtml (This folder contains lots of folders (containing .html files) and mainly "index.html" under it.
      ---- somexxxfolders
      ---- ---- somexxfolder's.html files
      ---- index.html
      ---- other etc files/folders

      - test-results (This contains some .xml files BUT only for either Unit tests or Integration tests - but not for both of the test types at a given time).

      i.e. if I run "gradle clean build", then you'll see Unit test related .xml files and if I run "gradle clean build integrationTest", then Unit test .xml files are overwritten and the .xml files I see are only related to/generated by integrationTest task.


      Following is one of the common gradle (GRADLE_HOME/init.d/some.common.gradle file)

      //
      //Extra file can hold global Gradle settings so that these dont have to be inserted in project
      //specific build.gradle file.
      //Filename: extraN.common<anyname>.gradle
      allprojects {
         apply plugin: 'java'
         apply plugin: 'pmd'
         apply plugin: 'findbugs'
         apply plugin: 'checkstyle'
         apply plugin: 'jacoco'
         apply plugin: 'sonar-runner'
         tasks.withType(Compile) {
           options.debug = true
           options.compilerArgs = ["-g"]
         }
         sourceSets {
            main {
               java {
                  // MOTE: If your project's build.gradle specify the sourceSet section, the following
                  // values will be overwritten by what project's build.gradle will set.
                  //
                  // If you project's sourceSet structure if different in each project, then in this
                  // global common .gradle file, you can define srcDir for main or other sections like
                  // test, integrationTest etc as shown below -- commented out. If that's the case, 
                  // then uncomment the below line and comment out using // -- srcDir 'src/java' line
                  // for sourceSets.main.java section. This rule applies to other sections as well.
                  // srcDir 'no_src_dir_set_yet'
      
                  srcDir 'src/java'
               }
               resources {
                  srcDir 'conf'
               }
            }
            test {
               java {
                  srcDir 'test/java'
               }
               resources {
                  srcDir 'test/resources'
                  srcDir 'conf'
               }
            }
            integrationTest {
               java {
                  srcDir 'src/java-test'
               }
               resources {
                  srcDir 'conf'
               }
            }
         }
         def sonarServerUrl = "dev.sandbox.server.com"
         sonarRunner {
            sonarProperties {
               property "sonar.host.url", "http://$sonarServerUrl:9000"
               property "sonar.jdbc.url", "jdbc:h2:tcp://$sonarServerUrl:9092/sonar"
               property "sonar.jdbc.driverClassName", "org.h2.Driver"
               property "sonar.jdbc.username", "sonar"
               property "sonar.jdbc.password", "sonar"
               properties ["sonar.sources"] += sourceSets.main.allSource.srcDirs
               //properties ["sonar.tests"] += sourceSets.test.java.srcDirs
               properties ["sonar.tests"] += sourceSets.integrationTest.allSource.srcDirs
            }
         }
         checkstyle {
              configFile = new File(rootDir, "config/checkstyle.xml")
              ignoreFailures = true
              //sourceSets = [sourceSets.main, sourceSets.test, sourceSets.integrationTest]
              sourceSets = [sourceSets.main]
         }
         findbugs {
              ignoreFailures = true
              sourceSets = [sourceSets.main]
         }
         pmd {
              ruleSets = ["basic", "braces", "design"]
              ignoreFailures = true
         }
         jacoco {
            toolVersion = "0.6.2.201302030002"
            reportsDir = file("$buildDir/customJacocoReportDir")
         }
         task testReport(type: TestReport) {
            destinationDir = file("$buildDir/reports/allTests")
         }
         test {
              jacoco {
                  //destinationFile = file("$buildDir/jacoco/jacocoTest.exec")
                  destinationFile = file("$buildDir/jacoco/test.exec")
                  //classDumpFile = file("$buildDir/jacoco/classpathdumps")
                  classDumpFile = file("$buildDir/build/classes/test")
              }
         }
         jacocoTestReport {
               group = "Reporting"
               description = "Generate Jacoco coverage reports after running tests."
               reports {
                      xml{
                          enabled true
                          destination "${buildDir}/reports/jacoco/jacoco.xml"
                      }
                      csv.enabled false
                      html{
                          enabled true
                          destination "${buildDir}/jacocoHtml"
                      }
              }
              additionalSourceDirs = files(sourceSets.main.allJava.srcDirs)
              //additionalSourceDirs = files([sourceSets.main.allJava.srcDirs, xxxx, 'xxxxyyyy' ])
         }
      }
      

      build.gradle file looks like:

      import com.tr.ids.gradle.CustomFileUtil
      apply plugin: 'CustomSetup'
      apply plugin: 'java'
      apply plugin: 'customJarService'
      apply plugin: 'customWarService'
      sourceSets {
         main {
            java {
               srcDir 'src/java'
            }
         }
         test {
            java {
               srcDir 'test/java'
            }
            resources {
               srcDir 'test/resources'
               srcDir 'conf'
            }
         }
         integrationTest {
            java {
               srcDir 'src/java-test'
            }
         }
      }
      // Read dependency lists from external files. Our custom plugin reads a dep-xxx.txt file for compile/test/war related .jar file entries
      // where each entry is like: groupid:artifactid:x.x.x
      // and these artifact jars are available in Artifactory
      List depListCompile = customFileUtil.readIntoList( "$projectDir/dep-compile.txt" )
      List depListTest = customFileUtil.readIntoList( "$projectDir/dep-testArtifacts.txt" )
      List depListWar = customFileUtil.readIntoList( "$projectDir/dep-war.txt" )
      // Define dependencies
      dependencies {
         // Compilation
         compile  depListCompile
         // Unit Tests
         testCompile depListTest
         // Integration tests
         // Everything from compile and testCompile targets
         integrationTestCompile configurations.compile
         integrationTestCompile configurations.testCompile
         // Output of compiling "main" files
         integrationTestCompile sourceSets.main.output
         // Additional dependencies from war and others
         integrationTestCompile depListTest, depListWar
         // All configuration files
         integrationTestRuntime files( 'conf' )
      }
      task deployTomcat( type: Copy, dependsOn: [ jar, compileIntegrationTestJava, warService ] ) {
         from "$buildDir/customWar/${project.name}.war"
         into "$projectDir/tomcat/webapps"
      }
      build {
        dependsOn deployTomcat
      }
      task integrationTest( type: Test, dependsOn: cleanTest ) {
         jacoco {
            //destinationFile = file("$buildDir/jacoco/jacocoTest.exec")
            destinationFile = file("$buildDir/jacoco/integrationTest.exec")
            //classDumpFile = file("$buildDir/jacoco/classpathdumps")
            classDumpFile = file("$buildDir/classes/integrationTest")
         }
         testClassesDir = sourceSets.integrationTest.output.classesDir
         classpath = sourceSets.integrationTest.runtimeClasspath
      }
      apply plugin: 'eclipse'
      eclipse.classpath {
         // Define output directory so Eclipse does not accidentally clobber /bin
         defaultOutputDir = file( 'out/classes' )
         // Add integration test
         plusConfigurations += configurations.integrationTestCompile
         // Remove unnecessary files
         file.whenMerged { classpath ->
            classpath.entries.removeAll { entry -> ( entry.path.indexOf( '/build/classes/main' ) > 0 ) }
            classpath.entries.removeAll { entry -> ( entry.path.indexOf( '/build/resources/main' ) > 0 ) }
         }
      }
      

      My questions:

      1) Why "gradle clean build integrationTest" -- which is working successfully, is overwriting test results in build/reports/tests and build/test-results folders.

      2) It doesn't matter what name I give for .exec file under common gradle file for test and in build.gradle for integrationTest task for jacoco, it always create test.exec and integrationTest.exec file but the resultant build/jacocoHtml folder index.html file doesn't show coverage / files related to both Unit / Integration tests. To prove this, if I run "gradle clean build integrationTest jacocoTestReport sonarRunner", I see the workspace for the job, now contains, ".sonar" folder and build/reports/sonar folder which contains another file called "overall-xxx.exec" some file, but that file size is not close to the "sum" of Unit test.exec and IT integrationTest.exec file size. Though its bigger than test.exec file size by few bytes.

      3) What configuration can I set to have overall coverage for both Unit and IT tests i.e. overall...exec file gets good size (after running sonarRunner task). During sonarRunner task, I do see SonarRunner task's "jacocoSensor step" does see both UT and IT .exec files and the overall .exec file as well automatically (a good feature from Sonar).

      解决方案

      Found answer to my 2nd question. High level info:

      1. Gradle 1.6 jacocoTestReport uses different variables, Gradle >=1.7 uses different.

        For ex: we can tweak Unit tests and Integration Tests .exec file creation by changing "test" or "integrationTest" task by using the CORRECT variables -or it wont work n generate "test.exec" and "integrationTest.exec" default file names. See example below.

      task integrationTest(type: Test) OR test { ... } section can have the correct variables for the given Gradle version that we are using.

      task integrationTest (type: Test) { 
      testClassesDir = sourceSets.integrationTest.output.classesDir
      
      classpath = sourceSets.integrationTest.runtimeClasspath
      
         testReportDir = file("$buildDir/reports/tests/IT")
         testResultsDir = file("$buildDir/test-results/IT")
      
      
      
        ignoreFailures = true
         jacoco {
      
       //This works with 1.6
       destPath = file("$buildDir/jacoco/IT/jacocoIT.exec")
       classDumpPath = file("$buildDir/jacoco/IT/classpathdumps")
      
       /*
       Following works only with versions >= 1.7 version of Gradle
       destinationFile = file("$buildDir/jacoco/IT/jacocoIT.exec")
       classDumpFile = file("$buildDir/jacoco/IT/classpathdumps")
       */
         }
      }
      

      Similarly, for test { .... } task, you can define it as ../../UT/jacocoUT.exec and ../../UT/classpathdumps...

      1. .sonar folder gets created if I run "sonar-runner" Linux/Unix sonar-runner executable in my project's workspace, BUT if I run Jenkins job which calls Gradle "clean build integrationTest jacocoTestReport sonarRunner", then build/sonar folder is created and becomes the WORKING DIR for SONAR (this shows up during the output).

      2. In Jenkins > under Post build section, I mentioned the following and NOW, jacoco code coverage report on Jenkins Dashboard for both jacoco files (.html and .xml) - includes Unit and Integration tests code coverage data.

      Record Jacoco coverage report section in Jenkins has the following boxes:

      I mentioned:

      Path to exec files: /build/jacoco/UT/jacocoUT.exec, */build/jacoco/IT/jacocoIT.exec Path to class dirs: */build/jacoco//classpathdumps/com/thc (this is the location where Jacoco instrumented classes sit).. both build/jacoco/UT/classpathdumps/com/thc and build/jacoco/IT/classpathdumps/com/thc will be picked as ** will be replaced for any folder under build/jacoco. this value can be set to "build/classes" folder as well.

      Path to source files: ** (if I use src/java, few of the links for source file don't work i.e. file contents don't show up).. used ** .. it works now.

      rest boxes - left blank.

      1. Still wondering - why overall-jacoco.exec is not having the file size = sum of both jacocoUT.exec and jacocoIT.exec

      At this point, I'm able to see Jacoco code coverage for both Unit and Integration Tests i.e. via visiting the Jacoco code coverage image on job's dashboard and visiting source code links and also if you go and browse "build/reports/jacoco/html/index.html" or "build/jacocoHtml/index.html" file.

      Still trying to find out - what needs to be done for SONAR to pick these 2 .exec files (I have valid values set for sonar.xxx variurs variables for sources, tests, binaries, ...reportsPath etc for UT / IT exec files... on SonarQube dashboard, Unit test coverage is showing up fine but Integration tests coverage is still 0.0%.

      I'll paste the copy of both my common.gradle and project's build.gradle file soon .... to have a better look.

      这篇关于Jacoco单元和集成测试覆盖 - 个人和整体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆