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

这条命令将重新编译您的

相关内容

热门资讯

实测分享!wepoker轻量版... 实测分享!wepoker轻量版辅助(辅助挂)总是存在有挂(详细教程)1、在wepoker轻量版辅助插...
重大来袭!大菠萝辅助器(辅助挂... 重大来袭!大菠萝辅助器(辅助挂)果然有挂(有挂技巧)1、首先打开大菠萝辅助器辅助器下载最新版本,在大...
每日必看教程!hhpkoer辅... 每日必看教程!hhpkoer辅助器(辅助挂)果然存在有挂(果真有挂)1.hhpkoer辅助器 选牌创...
重大消息!佛手在线有挂吗(辅助... 重大消息!佛手在线有挂吗(辅助挂)确实是有挂(有挂方法)1、首先打开佛手在线有挂吗辅助器下载最新版本...
玩家必看秘籍!竞技联盟辅助插件... 玩家必看秘籍!竞技联盟辅助插件(辅助挂)果然是真的有挂(揭秘有挂)暗藏猫腻,小编详细说明竞技联盟辅助...
热点讨论!wepoker游戏安... 热点讨论!wepoker游戏安装教程(辅助挂)竟然有挂(有挂技术)1)wepoker游戏安装教程辅助...
最新技巧!wepoker有透视... 最新技巧!wepoker有透视功能吗(辅助挂)一直是真的有挂(有挂细节)1、下载好wepoker有透...
记者揭秘!wepoker代打辅... 记者揭秘!wepoker代打辅助(辅助挂)确实真的是有挂(有挂教学)wepoker代打辅助辅助器是一...
一分钟教会你!拱趴大菠萝怎么开... 一分钟教会你!拱趴大菠萝怎么开挂(辅助挂)本来是真的有挂(存在有挂)1、任何拱趴大菠萝怎么开挂透视是...
一分钟了解!wepoker辅助... 一分钟了解!wepoker辅助分析器(辅助挂)果然真的有挂(有挂详细)1、很好的工具软件,可以解锁游...