AndroidGradle-SonarCloud集成中Jacoco插件的覆盖率始终为0.0%。
创始人
2024-10-08 01:31:34
0
  1. 在build.gradle文件中添加Jacoco插件:

build.gradle(Project)文件中的dependencies区域添加以下代码:

classpath "org.jacoco:org.jacoco.core:0.8.7"

build.gradle(Module)文件添加以下配置:

  • 在android区域添加:
buildTypes {
        debug {
            testCoverageEnabled = true
        }
    }
  • 在dependencies区域添加:
dependencies {
    implementation "androidx.test.ext:junit:1.1.2"
    androidTestImplementation "androidx.test.ext:junit:1.1.2"
    androidTestImplementation "androidx.test.espresso:espresso-core:3.3.0"
    debugImplementation 'androidx.fragment:fragment-testing:1.3.4'
    // Required as the Jacoco plugin is being applied to the debug build type only.
    debugImplementation "org.jacoco:org.jacoco.agent:0.8.7"
}
  1. 修改SonarScanner Gradle插件:

build.gradle文件中的dependencies区域添加以下代码:

classpath "org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:3.3"

在build.gradle(Module)文件添加以下配置:

plugins {
    id "org.sonarqube" version "3.3"
}

sonarqube {
    properties {
        property "sonar.projectKey", "your-project-key"
        property "sonar.organization", "your-org"
        property "sonar.host.url", "https://sonarcloud.io"
        property "sonar.branch.name", "your-branch-name"
        property "sonar.coverage.jacoco.xmlReportPaths", "${project.buildDir}/jacoco/testDebugUnitTest.exec"
        property "sonar.junit.reportPaths", "${project.buildDir}/test-results/testDebugUnitTest"
        
    }
}
  1. 运行Gradle任务:

在终端中输入以下命令:

./gradlew clean jacocoTestReport sonarqube

这条命令将重新编译您的

相关内容

热门资讯

6分钟辅助!wepoker插件... 您好,wepoker插件程序激活码这款游戏可以开挂的,确实是有挂的,需要了解加去威信【1367043...
5分钟辅助!pokemmo脚本... 5分钟辅助!pokemmo脚本辅助器,poker红龙辅助,烘培教程(有挂攻略)1、用户打开应用后不用...
三分钟辅助!aapoker安装... 三分钟辅助!aapoker安装包怎么使用,aa poker辅助,经验教程(有挂教程)1、实时aapo...
六分钟辅助!德普之星app安卓... 六分钟辅助!德普之星app安卓版破解版,hhpoker到底可以作弊吗,资料教程(有挂秘籍)1、打开软...
6分钟辅助!hhpoker辅助... 6分钟辅助!hhpoker辅助挂是真的吗,拱趴大菠萝怎么开挂,烘培教程(有挂助手)1、用户打开应用后...
三分钟辅助!德州局怎么透视,p... 三分钟辅助!德州局怎么透视,pokermaster脚本,练习教程(有挂解密)1、许多玩家不知道德州局...
第3分钟辅助!德州透视hhpo... 第3分钟辅助!德州透视hhpoker,wepoker破解是真的还是假的,指南书教程(讲解有挂)1、首...
第2分钟辅助!pokemmo脚... 第2分钟辅助!pokemmo脚本辅助,aapoker怎么设置抽水,资料教程(有挂工具)1、首先打开a...
第五分钟辅助!wepoker-... 第五分钟辅助!wepoker-h5下载,wepoker免费脚本弱密码,积累教程(新版有挂);wepo...
第九分钟辅助!wepoker辅... 第九分钟辅助!wepoker辅助脚本,wepoker轻量版有透视吗,窍门教程(有挂详细)wepoke...