我正在尝试设置jacoco我的项目的代码覆盖率
我的项目基于 Java 1.8
以下是我的项目中的内容 pom.xml
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.5.10.201208310627</version>
<configuration>
<output>file</output>
<append>true</append>
</configuration>
<executions>
<execution>
<id>jacoco-initialize</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>jacoco-site</id>
<phase>verify</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
然后我跑 mvn test,看到以下内容
$ mvn test
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building pennyapp 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- jacoco-maven-plugin:0.5.10.201208310627:prepare-agent (jacoco-initialize) @ pennyapp ---
[INFO] argLine set to -javaagent:/Users/harit/.m2/repository/org/jacoco/org.jacoco.agent/0.5.10.201208310627/org.jacoco.agent-0.5.10.201208310627-runtime.jar=destfile=/Users/harit/code/idea/pennyapp/target/jacoco.exec,append=true,output=file
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ pennyapp ---
[WARNING] Using platform encoding (UTF-8 actually) to …Run Code Online (Sandbox Code Playgroud) 我正在尝试让jacoco为我的android测试项目创建一个代码覆盖率报告.
Gradle版本 classpath 'com.android.tools.build:gradle:2.0.0'
我在build.gradle中有以下内容:
apply plugin: 'com.android.application'
apply plugin: 'jacoco'
jacoco {
toolVersion = "0.7.1.201405082137"
}
android {
buildTypes {
release {
}
debug {
testCoverageEnabled true
}
}
}
Run Code Online (Sandbox Code Playgroud)
几乎95%的代码覆盖率(当我在2015年运行相同的报告时,它显示报告为95%).从那时起,代码和测试文件夹中没有太大变化.理想情况下,它应该将覆盖范围显示为这样的东西
我尝试使用JDK7和8运行报告,但结果相同.还尝试更改为最新版本的JaCoCo,但结果仍然相同.
有什么想法为什么报告显示为0%的覆盖率?在运行Gradle任务时,它成功地在androidTest文件夹中运行我的测试.
