我一直在 Java Eclipse 中使用 Maven 项目为学校工作。我一直在使用 Eclemma 获取代码覆盖率数据,但我的教授想从命令行运行我的代码并从那里获取代码覆盖率报告。我一直在尝试让 Jacoco 工作,但我之前真的从未使用过 Maven 或 Pom.xmls,我很迷茫。这是我现在的样子
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId> yada yada yada </groupId>
<artifactId> yada yada yada </artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jacoco</groupId>
<artifactId>org.jacoco.ant</artifactId>
<version>0.8.1</version>
</dependency>
</dependencies>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.1</version>
<executions>
<execution>
<id>default-prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>post-integration-test</id>
<phase>post-integration-test</phase>
<goals>
<goal>report</goal>
</goals>
<configuration>
<dataFile>target/jacoco.exec</dataFile>
<outputDirectory>target/jacoco-ut</outputDirectory>
</configuration>
</execution>
当我执行
$> mvn clean test jacoco:report
或者只是jacoco:报告,我明白了
[INFO] --- jacoco-maven-plugin:0.8.1:report (default-cli) @ MyFileLocation ---
[INFO] Skipping JaCoCo execution due to missing execution data file.
不知道此时该怎么办...
BIG阳
蛊毒传说
相关分类