無法在項目上執行目標 org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test)。 (Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.)


問題描述

無法在項目上執行目標 org.apache.maven.plugins:maven‑surefire‑plugin:2.12:test (default‑test)。 (Failed to execute goal org.apache.maven.plugins:maven‑surefire‑plugin:2.12:test (default‑test) on project.)

幾天以來我一直在嘗試解決以下錯誤,但我無法解決它:(

我的模塊的 pom.xml 文件是:

<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>
<parent>
<artifactId>junitcategorizer</artifactId>
<groupId>com.topdesk.test.junitcategorizer</groupId>
<version>0.0.1‑SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>
<artifactId>junitcategorizer.instrument</artifactId>
<name>JUnitCategorizer InstrumentationAgent</name>
<description>The agent used to instrument the called Java classes</description>
<dependencies>
<dependency>
    <groupId>org.ow2.asm</groupId>
    <artifactId>asm‑commons</artifactId>
    <version>4.0</version>
</dependency>
<dependency>
    <groupId>junit</groupId>
    <artifactId>junit</artifactId>
    <version>4.10</version>
</dependency>
</dependencies>
<build>
<plugins>
  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven‑jar‑plugin</artifactId>
    <configuration>
      <archive>
        <manifest>
          <addClasspath>true</addClasspath>
        </manifest>
        <manifestEntries>
            <Premain‑Class>com.topdesk.junitcategorizer.instrument.InstrumentationAgent</Premain‑Class>
            <Agent‑Class>com.topdesk.junitcategorizer.instrument.InstrumentationAgent</Agent‑Class>
            <Can‑Redefine‑Classes>true</Can‑Redefine‑Classes>
            <Can‑Retransform‑Classes>true</Can‑Retransform‑Classes>
            <Boot‑Class‑Path>${project.artifactId}‑${project.version}.jar</Boot‑Class‑Path>
            <Can‑Set‑Native‑Method‑Prefix>true</Can‑Set‑Native‑Method‑Prefix>
        </manifestEntries>
      </archive>
    </configuration>
  </plugin>
  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven‑shade‑plugin</artifactId>
    <version>1.5</version>
    <executions>
      <execution>
        <phase>package</phase>
        <goals>
          <goal>shade</goal>
        </goals>
        <configuration> 
          <artifactSet>
            <includes>
              <include>org.ow2.asm:*</include>
            </includes>
          </artifactSet>
          <relocations>
            <relocation>
              <pattern>org.objectweb.asm</pattern>
              <shadedPattern>org.shaded.asm</shadedPattern>
            </relocation>
          </relocations>
        </configuration>
      </execution>
    </executions>
  </plugin>
 </plugins>
 </build>
 </project>

I我收到以下錯誤:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven‑surefire‑plugin:2.
12:test (default‑test) on project junitcategorizer.instrument: There are test failures.
[ERROR]
[ERROR] Please refer to D:\Masters\thesis related papers and tools\junitcategorizer\junitcategorizer.instrument\target\surefire‑reports for the individual test results.
[ERROR] ‑> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven‑surefire‑plugin:2.12:test (default‑test) on project junitcategorizer.instrument: There are test failures.

Please refer to D:\Masters\thesis related papers and tools\junitcategorizer\junitcategorizer.instrument\target\surefire‑reports for the individual test results.

    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:120)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:347)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:154)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:582)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:214)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:158)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
    Caused by: org.apache.maven.plugin.MojoFailureException: There are test failures.

    Please refer to D:\Masters\thesis related papers and tools\junitcategorizer\junitcategorizer.instrument\target\surefire‑reports for the individual test results.

    at org.apache.maven.plugin.surefire.SurefireHelper.reportExecution(SurefireHelper.java:83)
    at org.apache.maven.plugin.surefire.SurefirePlugin.writeSummary(SurefirePlugin.java:673)
    at org.apache.maven.plugin.surefire.SurefirePlugin.handleSummary(SurefirePlugin.java:647)
    at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeAfterPreconditionsChecked(AbstractSurefireMojo.java:137)
    at org.apache.maven.plugin.surefire.AbstractSurefireMojo.execute(AbstractSurefireMojo.java:98)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:132)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
    ... 19 more
    [ERROR]
    [ERROR] Re‑run Maven using the ‑X switch to enable full debug logging.

我嘗試了以下但沒有幫助:

  1. mvn dependency::tree
  2. mvn clean install ‑U或右鍵單擊“項目”轉到“Maven”>>“更新”

請幫助我!


參考解法

方法 1:

This solved my issue. It was 2.10 in my POM, just updated to 2.19.1 and refresh the POM

Add to your pom :

 <plugins>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven‑surefire‑plugin</artifactId>
          <version>2.19.1</version>
        </plugin>
  </plugins>

In your error code he didn't find surefire plugin so add it

方法 2:

This is what solves the problem:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven‑surefire‑plugin</artifactId>
    <version>2.19.1</version>
    <configuration>
        <testFailureIgnore>true</testFailureIgnore>
    </configuration>
</plugin>

from Failed to execute goal org.apache.maven.plugins:maven‑surefire‑plugin:2.10:test

方法 3:

This happens when Maven tries to run your test cases while building the jar. You can simply skip running the test cases by adding ‑DskipTests at the end of your maven command.

Ex: mvn clean install ‑DskipTests or mvn clean package ‑DskipTests

方法 4:

Was facing the same issue multiple times and I have 2 solutions:

Solution 1: Add surefire plugin reference to pom.xml. Watch that you have all nodes! In my IDEs auto import version was missing!!!

<plugins>
    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven‑surefire‑plugin</artifactId>
        <version>3.0.0‑M3</version>
    </plugin>
</plugins>

Solution 2: My IDE added wrong import to the start of the file.

IDE added

import org.junit.Test;

I had to replace it with

import org.junit.jupiter.api.Test;

方法 5:

Try this it works!

<plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven‑surefire‑plugin</artifactId>
                <version>3.0.0‑M3</version>
                <configuration>
                <testFailureIgnore>true</testFailureIgnore>
                <shutdown>kill</shutdown> <!‑‑ Use it if required‑‑>
                </configuration>
            </plugin>

(by SrinuHohenheimnikkTharun KumarelradoXpert)

參考文件

  1. Failed to execute goal org.apache.maven.plugins:maven‑surefire‑plugin:2.12:test (default‑test) on project. (CC BY‑SA 2.5/3.0/4.0)

#maven #maven-2






相關問題

jslint-maven-plugin 1.0.2-SNAPSHOT 存儲庫 (jslint-maven-plugin 1.0.2-SNAPSHOT repository)

當 Action 類位於單獨的 jar 文件中時,Struts 2 驗證失敗 (Struts 2 Validation failing when Action class sits in a separate jar file)

Marklogic 是否有 liquibase 等價物 (Is there a liquibase equivalent for Marklogic)

Jenkins插件開發不適用於maven 2 (Jenkins plugin development not working with maven 2)

無法構建 CloudHopper (SMPP) (Cannot build CloudHopper (SMPP))

如何使用 Maven 在目標(SVN-)服務器上創建 Javadoc? (How to create Javadoc on the target (SVN-) server using Maven?)

sbt 相當於 maven exec 插件 (sbt equivalent of maven exec plugin)

從 Ecplise 運行 Mule 應用程序時出現 NoSuchMethodError 異常 (NoSuchMethodError exception when run Mule Application from Ecplise)

intellij idea中-X和-e開關在哪裡打開 (Where to open the -X and -e switch in intellij idea)

無法在項目上執行目標 org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test)。 (Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.)

通過 Maven 運行 Tomcat 時如何將其綁定到特定接口? (How do you bind Tomcat to a specific interface when running it through Maven?)

如何配置必須使用“密碼”授權類型從授權服務器請求令牌的客戶端 Java 應用程序? (How do I configure a client Java application which must request a token from an authorization server using a 'password' grant type?)







留言討論