【问题标题】:Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M3:test (default-test) on project automation: There are test failures无法在项目自动化上执行目标 org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M3:test (default-test):有测试失败
【发布时间】:2019-08-05 17:10:02
【问题描述】:

无法使用以下方法运行单个测试: mvn -Dtest=SettingsTest#test* 测试

我已按照此处提到的步骤进行操作:https://maven.apache.org/surefire/maven-surefire-plugin/examples/single-test.html

它会抛出一个错误:

[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  4.225 s
[INFO] Finished at: 2019-03-14T11:00:10-07:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M3:test (default-test) on project automation: There are test failures.
[ERROR] 
[ERROR] Please refer to /Users/iOS-automation/target/surefire-reports for the individual test results.
[ERROR] Please refer to dump files (if any exist) [date].dump, [date]-jvmRun[N].dump and [date].dumpstream.
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

我的 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>

  <groupId>org.abc</groupId>
  <version>1.0-SNAPSHOT</version>
  <packaging>jar</packaging>
  <name>automation</name>
  <description>iOS app automation</description>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
  </properties>

  <build>
      <plugins>
          <plugin>
              <groupId>org.apache.maven.plugins</groupId>
              <artifactId>maven-surefire-plugin</artifactId>
              <version>3.0.0-M3</version>
              <configuration>
				  <suiteXmlFiles>
                      <suiteXmlFile>parth.xml</suiteXmlFile>
                  </suiteXmlFiles>
			  </configuration>
          </plugin>
          <plugin>
              <groupId>org.apache.maven.plugins</groupId>
              <artifactId>maven-compiler-plugin</artifactId>
              <version>3.5.1</version>
              <configuration>
                  <source>1.8</source>
                  <target>1.8</target>
              </configuration>
          </plugin>
      </plugins>
  </build>
  
  <dependencies>
    <dependency>
      	<groupId>junit</groupId>
     	<artifactId>junit</artifactId>
      	<version>3.8.1</version>
      	<scope>test</scope>
    </dependency>
    <dependency>
		<groupId>org.seleniumhq.selenium</groupId>
		<artifactId>selenium-java</artifactId>
		<version>2.47.1</version>
	</dependency>
	<dependency>
		<groupId>io.appium</groupId>
		<artifactId>java-client</artifactId>
		<version>4.1.2</version>
	</dependency>
	<dependency>
		<groupId>com.google.code.gson</groupId>
		<artifactId>gson</artifactId>
		<version>2.3.1</version>
	</dependency>
	<dependency>
	  <groupId>org.testng</groupId>
	  <artifactId>testng</artifactId>
	  <version>6.8</version>
      <scope>compile</scope>
	</dependency>
	<dependency>
		<groupId>com.google.googlejavaformat</groupId>
		<artifactId>google-java-format</artifactId>
		<version>1.5</version>
	</dependency>
	  <dependency>
		  <groupId>org.json</groupId>
		  <artifactId>json</artifactId>
		  <version>20180813</version>
	  </dependency>
	  <dependency>
		  <groupId>com.sun.jersey.contribs</groupId>
		  <artifactId>jersey-apache-client</artifactId>
		  <version>1.19.4</version>
	  </dependency>
	  <dependency>
		  <groupId>org.glassfish.jersey.core</groupId>
		  <artifactId>jersey-client</artifactId>
		  <version>2.27</version>
	  </dependency>
  </dependencies>
  <artifactId>automation</artifactId>
</project>

所有其他命令,例如:mvn clean install、mvn clean compile 工作正常。

我的 pom.xml 有问题还是设置有问题?

【问题讨论】:

  • 显示完整的错误信息。
  • @JFMeier 请看一下。我已添加完整的错误消息。
  • 您是否按照错误消息中的建议进行操作?
  • @JFMeier 是的,我做到了。但是没有什么可以提供更多细节。正如我在帖子“mvn clean install”“mvn compile”中提到的,没有任何理由可以正常工作。这是运行单个测试用例时的问题。
  • 所以你检查了测试报告?

标签: maven testng pom.xml


【解决方案1】:

你在你的项目中使用过任何插件吗?如以下文章所述,此异常不是来自 Maven,它是从插件生成的 https://cwiki.apache.org//confluence/display/MAVEN/MojoFailureException

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-06-28
    • 2020-02-24
    • 2020-03-30
    • 2016-07-25
    • 1970-01-01
    • 1970-01-01
    • 2014-11-03
    • 2018-05-28
    相关资源
    最近更新 更多