- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我正在尝试在我的 Android 项目上激活 Jacoco,用于单元测试(test
文件夹)和仪器测试(androidTest
文件夹)。真的,我对插桩测试最感兴趣,因为我的测试都放在这里。
我可以成功执行这两种类型的测试,但是当我尝试创建覆盖率报告(使用 gradlew createDebugCoverageReport
命令)时,没有考虑插桩测试。
此外,当我右键单击文件夹时,只有 test
文件夹中的测试显示“使用 Coverage 运行”选项,如果我转到“编辑配置”,则只有 JUnit 下的配置有“代码覆盖率”选项卡,在“Android 测试”配置中看不到它。
这是我的build.gradle:
apply plugin: 'com.android.application'
//apply plugin: "jacoco"
android {
compileSdkVersion 23
buildToolsVersion '23.0.2'
dexOptions {
javaMaxHeapSize "4g"
}
defaultConfig {
applicationId "com.abc.myapp"
minSdkVersion 19
targetSdkVersion 23
versionCode 1
versionName "1.0"
// Enabling multidex support.
multiDexEnabled true
// testInstrumentationRunner 'com.android.test.runner.MultiDexTestRunner'
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
testCoverageEnabled false
}
debug {
debuggable true
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
testCoverageEnabled true
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
testOptions {
unitTests.returnDefaultValues = true
}
productFlavors {
}
sourceSets {
main {
resources.srcDirs = ['src/main/java']
}
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
// androidTest.setRoot('src/androidTest')
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/notice.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/dependencies.txt'
exclude 'META-INF/LGPL2.1'
exclude 'NOTICE'
exclude 'LICENSE.txt'
exclude 'LICENSE'
exclude 'asm-license.txt'
}
configurations.all {
resolutionStrategy {
force 'com.android.support:support-annotations:23.0.1'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:multidex:1.0.1'
compile 'com.android.support:appcompat-v7:24.1.1'
androidTestCompile 'com.android.support:support-annotations:24.0.0'
androidTestCompile 'com.android.support.test:runner:0.5'
androidTestCompile 'com.android.support.test:rules:0.5'
// Optional -- Hamcrest library
androidTestCompile 'org.hamcrest:hamcrest-library:1.3'
// // Optional -- UI testing with Espresso
// androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2'
// // Optional -- UI testing with UI Automator
// androidTestCompile 'com.android.support.test.uiautomator:uiautomator-v18:2.1.2'
androidTestCompile 'org.mockito:mockito-core:1.10.19'
androidTestCompile 'com.google.dexmaker:dexmaker:1.2'
androidTestCompile 'com.google.dexmaker:dexmaker-mockito:1.2'
androidTestCompile 'junit:junit:4.12'
testCompile 'junit:junit:4.12'
}
最佳答案
gradlew createDebugAndroidTestCoverageReport 为应用模块中的仪器测试创建代码覆盖率报告,您可以在其中找到它
/build/reports/coverage/debug > index.html
关于android - Jacoco 代码覆盖 Android Studio 不考虑 androidTest 文件夹,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39856273/
我在我的一个模块中通过 JaCoCo 生成 AHP 报告时遇到问题。当构建开始时,我看到 JaCoCo 正确设置 argLine 为: [INFO] jacoco.agent.argLine set
我正在尝试将 JaCoCo 添加到我的 Android 以覆盖 Sonar Qube。但是在运行命令 ./gradlew jacocoTestReport 时,我收到以下错误。 Task :app:
我用过 lombok.@UtilityClass到: 生成私有(private)构造函数 使类(class)最终 将实用程序类中的所有字段设为静态 并且 Jacoco 不涵盖 Lombok 生成的代码
我正尝试在我的 project 上创建一个 jacoco 报告.该项目是 java 12 版本,jacoco-maven-plugin 是 0.8.5 版本。
我的项目是使用 Maven 构建的。我使用“Jacoco”插件来执行质量检查。 对于一个项目,我想在线检查测试覆盖率。我只想检查仅 3 个包裹的线路覆盖率。如何指定此检查? 我尝试“包括”一些软件包,
我有一个 Maven 项目(Java)的 jacoco-agent 生成文件,名为 jacoco.exec . 如何将此文件转换为人类可读的格式? (HTML/XML)。 最佳答案 我相信这是在 of
我正在使用 Bamboo、SonarQube 和 Maven 插件在 SonarQube 中生成 Jacoco 报告。它正在生成 jacoco.exec 文件,但如何在 SonarQube 中显示报告
我正在运行 Jacoco 的 Maven 插件。 prepare-agent 目标运行良好,但由于某种原因没有生成 jacoco.exec 文件。随后,报告目标提示由于缺少执行数据文件而跳过 JaCo
我在我的项目中设置了 Jacoco 来执行 a) 检查代码覆盖率和 b) 生成覆盖率报告。生成的 HTML 报告显示了正确的覆盖率值,但 Jacoco 检查在构建过程结束时生成的警告消息显示了不同的错
我用的是官方example Socket server为我的 jacocoagent.jar 启动一个套接字服务器来连接。我这样启动我的目标 jar : java -javaagent:jacocoa
当 Jacoco 代码覆盖率低于一定百分比时,我试图使 Gradle 构建失败。 ...
我有一个 maven 项目,使用“测试”阶段和“集成测试”阶段。在测试阶段,执行 JUnit 测试,在集成测试中有 HTMLUnit 测试。我正在使用 Jacoco[1]-maven-plugin 来
我遇到以下错误: Plugin execution not covered by lifecycle configuration: org.jacoco:jacoco-maven-plugin:0.7
我在 Tomcat 上部署了一个 Web 应用程序。在我进入更多细节之前,让我详细说明这些版本。 版本:jdk 1.7,Tomcat - 7.0.19,jacoco -0.5.6 我已将jdk1.7
我按照以下步骤使用 jacoco 测量代码覆盖率: 我已经使用 jacoco 代理动态检测了我的应用程序 wars 文件。 启动 tomcat 服务器。 运行一些测试用例。 已停止 tomcat 服务
我将我的 Ant 任务配置为
我正在尝试让 jacoco+gradle 一起工作。看看这个论坛,似乎有些人已经成功地做到了。但是当我尝试时,我遇到了一个奇怪的异常。 我做了什么: 1.下载gradle 2.2.1并配置环境变量等。
我正在开发 SAML One Login Toolkit,并从 GitHub 获取了最新的主分支 here并使用 Eclipse Oxygen。它应该手动解决所有 Maven 依赖项,但不幸的是事实并
SonarQube 7.7 针对 Java 项目分析显示以下警告: Property 'sonar.jacoco.reportPath' is deprecated (JaCoCo binary fo
我有一个在 jboss 7.1.3 上部署并使用 arquillian 进行测试的项目,我正在尝试向其中添加代码覆盖率指标。 我正在使用托管容器选项(jboss-as-arquillian-conta
我是一名优秀的程序员,十分优秀!