相关疑难解决方法(0)

在执行JaCoCo时获取"由于缺少执行数据文件而跳过JaCoCo执行"

我正在使用Maven 3.0.3,JUnit 4.8.1和Jacoco 0.6.3.201306030806,我正在尝试创建测试覆盖率报告.

我有一个只有单元测试的项目,但我无法运行报告,我反复收到错误:Skipping JaCoCo execution due to missing execution data file当我运行时:

mvn clean install -P test-coverage
Run Code Online (Sandbox Code Playgroud)

这是我的pom配置方式:

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-surefire-plugin</artifactId>
  <version>2.14.1</version>
  <configuration>
    <reuseForks>true</reuseForks>
    <argLine>-Xmx2048m</argLine>
  </configuration>
</plugin>
<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-failsafe-plugin</artifactId>
  <version>2.14.1</version>
  <configuration>
    <reuseForks>true</reuseForks>
    <argLine>-Xmx4096m -XX:MaxPermSize=512M ${itCoverageAgent}</argLine>
  </configuration>
  <executions>
    <execution>
      <goals>
        <goal>integration-test</goal>
        <goal>verify</goal>
      </goals>
    </execution>
  </executions>
</plugin>
...
<profile>
  <id>test-coverage</id>
  <build>
    <plugins>
      <plugin>
        <groupId>org.jacoco</groupId>
        <artifactId>jacoco-maven-plugin</artifactId>
        <version>0.6.3.201306030806</version>
        <configuration>
          <destfile>${basedir}/target/coverage-reports/jacoco-unit.exec</destfile>
          <datafile>${basedir}/target/coverage-reports/jacoco-unit.exec</datafile>
        </configuration>
        <executions>
          <execution>
            <id>prepare-unit-tests</id>
            <goals>
              <goal>prepare-agent</goal>
            </goals>
          </execution>
          <!-- prepare agent for measuring integration tests -->
          <execution>
            <id>prepare-integration-tests</id>
            <goals> …
Run Code Online (Sandbox Code Playgroud)

junit maven jacoco

92
推荐指数
11
解决办法
9万
查看次数

运行单元测试时出现IntelliJ错误:无法找到或加载主类$ {surefireArgLine}

在IntelliJ中运行单元测试时出现以下错误:错误:无法找到或加载主类$ {surefireArgLine}.我正在使用maven,在pom.xml中我有:

<properties>
    ...
    <surefire.argLine />
</properties>

<build>
    <plugins>
        <plugin>
            <groupId>com.mysema.maven</groupId>
            <artifactId>apt-maven-plugin</artifactId>
            <version>1.1.1</version>
            <executions>
                <execution>
                    <goals>
                        <goal>process</goal>
                    </goals>
                    <configuration>
                        <outputDirectory>target/generated-sources/java</outputDirectory>
                        <processor>com.mysema.query.apt.jpa.JPAAnnotationProcessor</processor>
                    </configuration>
                </execution>
            </executions>
        </plugin>

        <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>2.17</version>
        <configuration>
             <!--Sets the VM argument line used when unit tests are run.-->
            <argLine>${surefire.argLine}</argLine>
        </configuration>
    </plugin>
  <plugin>
            <groupId>org.jacoco</groupId>
            <artifactId>jacoco-maven-plugin</artifactId>
            <version>0.7.1.201405082137</version>
            <executions>
                <!--
                    Prepares the property pointing to the JaCoCo runtime agent which
                    is passed as VM argument when Maven the Surefire plugin is executed.
                -->
                <execution>
                    <id>pre-unit-test</id>
                    <goals>
                        <goal>prepare-agent</goal>
                    </goals>
                    <configuration>
                        <!--Sets …
Run Code Online (Sandbox Code Playgroud)

junit intellij-idea maven-surefire-plugin

61
推荐指数
2
解决办法
3万
查看次数

Maven JaCoCo插件错误

我在我的pom.xml文件中配置了Maven JaCoCo插件,如下所示:

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <jacoco.version>0.5.9.201207300726</jacoco.version>
</properties>

<profiles>
    <profile>
        <id>jacoco4</id>
        <build>
            <plugins>
                <plugin>
                    <groupId>org.jacoco</groupId>
                    <artifactId>jacoco-maven-plugin</artifactId>
                    <version>${jacoco.version}</version>
                    <executions>
                        <execution>
                            <goals>
                                <goal>prepare-agent</goal>
                            </goals>
                            <configuration
                            <destfile>${project.build.directory}/target/jacoco.exec</destfile>
                            <datafile>${project.build.directory}/target/jacoco.exec</datafile>
                                <output>file</output>
                                <append>true</append>
                            </configuration>
                        </execution>
                        <execution>
                            <id>report</id>
                            <phase>prepare-package</phase>
                            <goals>
                                <goal>report</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </build>
    </profile>
</profiles>
Run Code Online (Sandbox Code Playgroud)

我正在使用Windows 7和apache-maven-3.0.4插件.当我mvn -P jacoco4 install从cygwin终端或命令提示终端输入时,Maven下载并运行JaCoCo插件,但是该jacoco.exec文件似乎没有被创建.以下是错误消息:

[ERROR] Unable to read execution data file C:\Users\brownru\workspace64new\vps9\vps-fileserver\target\jacoco.exec: C:\Users\brownru\workspace64new\vps9\vps-fileserver\target\jacoco.exec (The system cannot find the file specified)
java.io.FileNotFoundException: C:\Users\brownru\workspace64new\vps9\vps-fileserver\target\jacoco.exec (The system cannot find the file specified)
        at java.io.FileInputStream.open(Native Method)
        at java.io.FileInputStream.<init>(FileInputStream.java:120)
        at …
Run Code Online (Sandbox Code Playgroud)

xml maven-plugin maven jacoco

21
推荐指数
4
解决办法
4万
查看次数

JaCoCo with Maven - 缺少执行数据文件

我们有一个Maven多模块项目,由父(HelloWorld)和不同的子(HelloWorldServices和HelloWorldPresentation)组成,并使用Jenkins构建.

运行成功测试后的错误是

[INFO] --- jacoco-maven-plugin:0.7.6.201602180812:report (default-cli) @ HelloWorldServices ---
[INFO] Skipping JaCoCo execution due to missing execution data file:/var/lib/jenkins/workspace/HelloWorld/HelloWorldServices/target/jacoco.exec
Run Code Online (Sandbox Code Playgroud)

它之前的线条说

[INFO] --- jacoco-maven-plugin:0.7.6.201602180812:prepare-agent (default-cli) @ HelloWorldServices ---
[INFO] argLine set to -javaagent:/var/lib/jenkins/.m2/repository/org/jacoco/org.jacoco.agent/0.7.6.201602180812/org.jacoco.agent-0.7.6.201602180812-runtime.jar=destfile=/var/lib/jenkins/workspace/HelloWorld/HelloWorldServices/target/jacoco.exec
Run Code Online (Sandbox Code Playgroud)

这是我定义父pom JaCoCo插件的方式:

<plugin>
    <groupId>org.jacoco</groupId>
    <artifactId>jacoco-maven-plugin</artifactId>
    <version>0.7.6.201602180812</version>
    <configuration>
        <destfile>${project.artifactId}/target/jacoco.exec</destfile>
        <datafile>${project.artifactId}/target/jacoco.exec</datafile>
    </configuration>

    <executions>
        <execution>
            <id>jacoco-initialize</id>
            <goals>
                <goal>prepare-agent</goal>
            </goals>
        </execution>
        <execution>
            <id>jacoco-site</id>
            <phase>package</phase>
            <goals>
                <goal>report</goal>
            </goals>
        </execution>
    </executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)

在没有pom的情况下,我明确提到了万无一失.我也尝试了你在任何地方找到的argLine配置,但都具有相同的结果.无论我做什么,JaCoCo .exec文件从未创建过.至于目标,我用

mvn clean install jacoco:prepare-agent jacoco:report
Run Code Online (Sandbox Code Playgroud)

因为当我省略jacoco目标时,它甚至不显示INFO消息.

java pom.xml maven-3 maven jacoco-maven-plugin

18
推荐指数
3
解决办法
2万
查看次数

jacoco的prepare-agent没有生成jacoco.exec文件

我正在运行Jacoco的Maven插件.该prepare-agent目标运行正常,但不会产生jacoco.exec由于某种原因文件.随后report目标抱怨Skipping JaCoCo execution due to missing execution data file.

有任何想法吗?

maven jacoco

17
推荐指数
1
解决办法
2万
查看次数

来自JaCoCo Maven插件的SonarQube集成测试覆盖率显示0%

我们有一个多模块多语言maven java项目,使用jacoco进行覆盖分析.模块的主要部分是带有REST API的后端(Java代码),我们的webapp模块包含前端(AngularJS)和java中的Integration-Tests.我们的Jacoco-IT.exec文件包含大约100Kb的数据,因此我们猜测可以收集集成测试的一些Coverage数据.然而,我们无法在SonarQube中看到任何报道(使用版本5.0和4.5)

我们运行构建项目并运行集成测试

mvn clean install
Run Code Online (Sandbox Code Playgroud)

用数据分析数据

mvn sonar:sonar
Run Code Online (Sandbox Code Playgroud)

项目配置为多语言,但我们只是分析了java代码(我们曾经有过单语言配置,但与覆盖数据相关的结果没有差异)

我们的父母POM:

<properties>
    <hibernate.version>4.2.2.Final</hibernate.version>
    <spring.version>3.2.3.RELEASE</spring.version>
    <resteasy.version>3.0.4.Final</resteasy.version>
    <cucumber.version>1.1.3</cucumber.version>
    <selenium-java.version>2.33.0</selenium-java.version>
    <!-- Sonar -->
    <sonar.java.coveragePlugin>jacoco</sonar.java.coveragePlugin>
    <sonar.dynamicAnalysis>reuseReports</sonar.dynamicAnalysis>
    <sonar.jacoco.itReportPath>${project.basedir}/../target/jacoco-it.exec</sonar.jacoco.itReportPath>
    <jacoco.dataFile>${project.basedir}/../target/jacoco-it.exec</jacoco.dataFile>
</properties>
<build>
   <plugins>
       <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                <source>1.7</source>
                <target>1.7</target>
                <debug>true</debug>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.jacoco</groupId>
            <artifactId>jacoco-maven-plugin</artifactId>

            <executions>
                <execution>
                    <id>default-prepare-agent</id>
                    <goals>
                        <goal>prepare-agent</goal>
                    </goals>
                </execution>
                <execution>
                    <id>default-prepare-agent-integration</id>
                    <goals>
                        <goal>prepare-agent-integration</goal>
                    </goals>
                </execution>
                <execution>
                    <id>default-report</id>
                    <goals>
                        <goal>report</goal>
                    </goals>
                </execution>
                <execution>
                    <id>default-report-integration</id>
                    <goals>
                        <goal>report-integration</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.16</version>
        </plugin>
    </plugins>
    <pluginManagement>
            <plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
                <version>0.7.2.201409121644</version>
            </plugin>
    </pluginMangement> …
Run Code Online (Sandbox Code Playgroud)

configuration integration-testing maven sonarqube jacoco-maven-plugin

14
推荐指数
1
解决办法
8482
查看次数

Maven 动态更改属性(运行时)

我遇到了以下问题:我希望能够使用插件即时更改 Maven 属性。例如,如果我配置了一个属性,例如:

<properties>
   <someProperty>value</someProperty>
</properties>
Run Code Online (Sandbox Code Playgroud)

我想有一种方法在 maven 运行期间将其更改为“value-2”(不是之前!例如,我不想在命令行中使用 -DsomeProperty=value-2)

我将尝试解释我的用例以澄清:我的 pom.xml 设置了一些默认属性。但是,我正在运行一个任务,该任务创建一个带有 name=value 对的属性文件以匹配我的属性(例如,如果我的 pom.xml 中有诸如 someProperty=value 之类的属性,则 run.properties 文件具有 someProperty=value- 2 财产)。在某些 maven 运行期间,我想将我的属性文件的位置传递给它,并让它更改我的 pom.xml 中的默认属性。我曾尝试使用“properties-maven-plugin”来实现这一目标,但这似乎只有在我没有在 pom.xml 本身中配置属性时才有效。也就是说,如果我的 pom.xml 中的部分没有“someProperty”属性,则更改成功。如果我有的话

有什么建议?提前致谢

properties maven

5
推荐指数
1
解决办法
2万
查看次数

即使配置了,Maven 安装也不会以 UTF-8 进行编码

您好,我的项目编码有问题。

\n\n

当我从 eclipse 运行 JUnit 测试时,没有失败。问题是当我执行 maven > clean maven > install 时,其中一项测试失败。

\n\n

我有这个字符串:“ADMINISTRACI\xc3\x93N”,当我从 Eclipse 运行 JUnit 时一切都很好,但是我已经打印了该变量,当 Maven 进行测试时,该字符串的值是:“管理 \xef\xbf\xbdN"。

\n\n

我已经将 Eclipse 中编码的每个属性更改为 UTF-8。\n-以这种方式配置 pom:

\n\n
      (...)\n      <project>\n        <properties>\n            <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>\n            (...)\n       </properties>\n      </project>\n      (...)\n      <plugins>\n        <plugin>\n            <groupId>org.apache.maven.plugins</groupId>\n            <artifactId>maven-compiler-plugin</artifactId>\n            <version>3.6.0</version>\n            <configuration>\n              <encoding>UTF-8</encoding>\n                <source>1.7</source>\n                <target>1.7</target>\n            </configuration>\n        </plugin>\n     </plugins>\n     (...)\n
Run Code Online (Sandbox Code Playgroud)\n\n

但输出是一样的。我有一个同事和我有相同的项目,有相同的 Eclipse 客户端和配置,她的 Maven 测试打印重音没有任何问题。

\n\n

还有其他想法吗?

\n\n

多谢!

\n

java testing encoding utf-8 maven

1
推荐指数
1
解决办法
3111
查看次数