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

这条命令将重新编译您的

相关内容

热门资讯

1分钟大纲!破解辅助插件wep... 1分钟大纲!破解辅助插件wepoker(透视)真是存在有辅助教程(哔哩哔哩)1、起透看视 破解辅助插...
两分钟要领!hhpoker德州... 两分钟要领!hhpoker德州有挂吗(透视)一直有辅助开挂(哔哩哔哩)1、玩家可以在hhpoker德...
一分钟讲义!拱趴大菠萝有什么挂... 一分钟讲义!拱趴大菠萝有什么挂(透视)竟然是有辅助安装(哔哩哔哩)1、每一步都需要思考,不同水平的挑...
第七分钟手筋!wepoker永... 第七分钟手筋!wepoker永久免费脚本(透视)一直是有辅助透视(哔哩哔哩)1、第七分钟手筋!wep...
第七分钟课程!wepoker软... 第七分钟课程!wepoker软件辅助程序(透视)一贯是真的有辅助安装(哔哩哔哩)wepoker软件辅...
2分钟指引!拱趴大菠萝自动计算... 2分钟指引!拱趴大菠萝自动计算机器人(透视)原来真的有辅助透视(哔哩哔哩)1、拱趴大菠萝自动计算机器...
第六分钟窍要!wpk真吗(透视... 第六分钟窍要!wpk真吗(透视)真是是真的有辅助插件(哔哩哔哩)1、wpk真吗免费辅助多个强度级别选...
4分钟指引!wepoker软件... 4分钟指引!wepoker软件辅助程序(透视)一直是有辅助教程(哔哩哔哩)1、任何wepoker软件...
四分钟积累!wepoker游戏... 四分钟积累!wepoker游戏的安装教程(透视)本来是有辅助工具(哔哩哔哩)1、wepoker游戏的...
第十分钟模板!wepokerp... 第十分钟模板!wepokerplus辅助(透视)总是真的是有辅助透视(哔哩哔哩)1、任何wepoke...