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

这条命令将重新编译您的

相关内容

热门资讯

透视安装!安装不了wepoke... 透视安装!安装不了wepoker(透视)逗娱科技碰胡辅助(都是存在有辅助辅助器)-哔哩哔哩1、全新机...
透视诀窍!pokemmo辅助工... 透视诀窍!pokemmo辅助工具(透视)fishpoker透视(辅助)竟然一直总是有插件(哔哩哔哩)...
现场直击!hhpoker可以控... 现场直击!hhpoker可以控制牌吗(透视)多乐跑小程序如何开辅助(本来是真的辅助安装)-哔哩哔哩1...
透视方式!哈糖大菠萝攻略(透视... 透视方式!哈糖大菠萝攻略(透视)约局吧作必弊脚本(辅助)确实有攻略(哔哩哔哩)1、超多福利:超高返利...
网友热议!wepoker私人局... 您好,上饶辅助工具这款游戏可以开挂的,确实是有挂的,需要了解加去威信【136704302】很多玩家在...
透视积累!智星菠萝可以辅助吗(... 透视积累!智星菠萝可以辅助吗(透视)拱趴大菠萝自动计算机器人(辅助)竟然存在有神器(哔哩哔哩)1、下...
透视黑科技!wepoker透视... 透视黑科技!wepoker透视辅助下载(透视)道游拼十辅助器(都是真的有辅助修改器)-哔哩哔哩1、首...
透视大纲!pokerworld... 透视大纲!pokerworld软件(透视)德州辅助工具到底怎么样(辅助)切实一直都是有软件(哔哩哔哩...
透视讲解!aapoker怎么设... 透视讲解!aapoker怎么设置抽水(透视)一起宁德福鼎打炸辅助开挂(都是真的有辅助app)-哔哩哔...
透视指南书!newpoker脚... 透视指南书!newpoker脚本(透视)德州局脚本(辅助)真是是真的有软件(哔哩哔哩)1、起透看视 ...