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

这条命令将重新编译您的

相关内容

热门资讯

一直以来"hhpok... 一直以来"hhpoker德州有挂吗"werplan外开挂(切实是有辅助平台)-哔哩哔哩1、操作简单,...
据监测"大菠萝789... 据监测"大菠萝789辅助器下载"hhpoker有透视功能吗(切实是真的辅助平台)-哔哩哔哩1、大菠萝...
截至目前"wepok... 截至目前"wepoker软件安装包"wpk透视辅助下载(好像真的有辅助修改器)-哔哩哔哩wepoke...
备受关注的"hhpo... 备受关注的"hhpoker免费透视脚本"德扑圈透视(原来是有辅助插件)-哔哩哔哩1、hhpoker免...
透视插件"wepok... 透视插件"wepoker免费脚本咨询"wepoker代打辅助(真是是有辅助软件)-哔哩哔哩1、wep...
据文件显示"德普之星... 据文件显示"德普之星透视辅助软件"wepoker透视脚本免费使用视频(竟然是真的辅助插件)-哔哩哔哩...
在玩家背景下"wep... 在玩家背景下"wepoker科技辅助器"wepoker透视苹果系统(好像是有辅助工具)-哔哩哔哩we...
据通报"wepoke... 据通报"wepoker作必弊方法"wepoker手机插件(切实真的有辅助下载)-哔哩哔哩;1、金币登...
透视安卓版"we-p... 透视安卓版"we-poker靠谱吗"wepoker插件程序激活码(好像有辅助插件)-哔哩哔哩1、透视...
随着"wpk私人局有... 随着"wpk私人局有透视吗"wepoker破解工具(果然是有辅助修改器)-哔哩哔哩随着"wpk私人局...