无法在 Jzy3d 程序的子模块上执行目标 Maven Surefire 插件
Failure to Execute Goal Maven Surefire Plugin on Child Module for Jzy3d Program
为了简化我的问题:什么是测试失败以及如何纠正它?
我是 Maven 的新手,我正在尝试让图形绘图应用程序 Jzy3d 在我的计算机上运行。我已经将所有插件更新为父模块和子模块的 POM 文件中的最新版本,并检查 Maven 是否指向我安装的最新 JRE(确实如此)。
我的依赖树也很好,涵盖了我在这个论坛和其他地方看到这个错误的许多途径。
我根本无法隔离问题。
运行mvn package -e时报错信息如下:
D:\Program Files\jzy3d-api-master>mvn package -e
[INFO] Error stacktraces are turned on.
[INFO] Scanning for projects...
[INFO]
------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] Jzy3d Master Project
[INFO] JDT core (fork of https://github.com/yonatang/JDT)
[INFO] Jzy3d API
[INFO] Jzy3d SWT Tools
[INFO] Jzy3d Tutorials
[INFO]
[INFO]
------------------------------------------------------------------------
[INFO] Building Jzy3d Master Project 0.9.2-SNAPSHOT
[INFO]
------------------------------------------------------------------------
[INFO]
[INFO]
------------------------------------------------------------------------
[INFO] Building JDT core (fork of https://github.com/yonatang/JDT)
0.9.2-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ jzy3d-jdt-core ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory D:\Program Files\jzy3d-api-master\jzy3d-jdt-core\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.3:compile (default-compile) @ jzy3d-jdt-core ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ jzy3d-jdt-core ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 18 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.3:testCompile (default-testCompile) @ jzy3d-jdt-core ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.19.1:test (default-test) @ jzy3d-jdt-core ---
[INFO] Surefire report directory: D:\Program Files\jzy3d-api-master\jzy3d-jdt-core\target\surefire-reports
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running il.ac.idc.jdt.SmokeTest Configuring TestNG with: TestNG60Configurator Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 2.639 sec <<< FAILURE! - in il.ac.idc.jdt.SmokeTest shouldRunOnExampleData(il.ac.idc.jdt.SmokeTest) Time elapsed: 0.412 sec <<< FAILURE! java.lang.AssertionError: t1_1000.tsin trangulation is correct for smf
at il.ac.idc.jdt.SmokeTest.shouldRunOnExampleData(SmokeTest.java:28)
Results :
Failed tests: SmokeTest.shouldRunOnExampleData:28 t1_1000.tsin trangulation is correct for smf
Tests run: 1, Failures: 1, Errors: 0, Skipped: 0
[INFO]
------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] Jzy3d Master Project ............................... SUCCESS [ 0.022 s]
[INFO] JDT core (fork of https://github.com/yonatang/JDT) . FAILURE [ 8.853 s]
[INFO] Jzy3d API .......................................... SKIPPED
[INFO] Jzy3d SWT Tools .................................... SKIPPED
[INFO] Jzy3d Tutorials .................................... SKIPPED
[INFO]
------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO]
------------------------------------------------------------------------
[INFO] Total time: 9.772 s
[INFO] Finished at: 2016-01-13T11:56:26+00:00
[INFO] Final Memory: 8M/22M
[INFO]
------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.19.1:test (default-test) on project jzy3d-jdt-core: There are test failures.
[ERROR]
[ERROR] Please refer to D:\Program Files\jzy3d-api-master\jzy3d-jdt-core\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.19.1:test (default-test) on project jzy3d-jdt-core: There are test failures.
Please refer to D:\Program Files\jzy3d-api-master\jzy3d-jdt-core\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:128)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
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:\Program Files\jzy3d-api-master\jzy3d-jdt-core\target\surefire-reports for the individual test results.
at org.apache.maven.plugin.surefire.SurefireHelper.reportExecution(SurefireHelper.java:91)
at org.apache.maven.plugin.surefire.SurefirePlugin.handleSummary(SurefirePlugin.java:320)
at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeAfterPreconditionsChecked(AbstractSurefireMojo.java:892)
at org.apache.maven.plugin.surefire.AbstractSurefireMojo.execute(AbstractSurefireMojo.java:755)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
... 20 more [ERROR] [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 [ERROR] [ERROR] After correcting the problems, you can resume the build with the command [ERROR] mvn <goals> -rf :jzy3d-jdt-core
我的父 POM 文件是:
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.jzy3d</groupId>
<artifactId>jzy3d-master</artifactId>
<version>0.9.2-SNAPSHOT</version>
<packaging>pom</packaging>
<name>Jzy3d Master Project</name>
<url>http://www.jzy3d.org</url>
<description>A java API to draw 3d charts.</description>
<developers>
<developer>
<id>martin.pernollet</id>
<name>Martin Pernollet</name>
<email>martin@jzy3d.org</email>
<url>http://twitter.com/jzy3d</url>
</developer>
<developer>
<id>nils.hoffmann</id>
<name>Nils Hoffmann</name>
</developer>
<developer>
<id>juan.barandiaran</id>
<name>Juan Barandiaran</name>
</developer>
</developers>
<licenses>
<license>
<name>The (New) BSD License</name>
<url>http://www.opensource.org/licenses/bsd-license.php</url>
<distribution>repo</distribution>
</license>
</licenses>
<scm>
<connection>scm:git:git://github.com/jzy3d/jzy3d-api</connection>
</scm>
<issueManagement>
<system>Github</system>
<url>https://github.com/jzy3d/jzy3d-api/issues</url>
</issueManagement>
<modules>
<module>jzy3d-api</module>
<!-- <module>jzy3d-javafx</module> -->
<module>jzy3d-swt</module>
<module>jzy3d-jdt-core</module>
<module>jzy3d-tutorials</module>
</modules>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<version.jzy3d>0.9.2-SNAPSHOT</version.jzy3d>
<version.java.source>1.6</version.java.source>
<version.java.target>1.6</version.java.target>
<version.mvn.compiler>3.0</version.mvn.compiler>
<version.mvn.ftp>1.0-beta-6</version.mvn.ftp>
<version.mvn.deploy>2.4</version.mvn.deploy>
<version.mvn.javadoc>2.9.1</version.mvn.javadoc>
<version.libs.junit>4.10</version.libs.junit>
<version.libs.swt>4.2.1</version.libs.swt>
</properties>
<distributionManagement>
<repository>
<id>jzy3d-ftp</id>
<name>Jzy3d Maven Folder</name>
<url>ftp://ftp.cluster013.ovh.net/maven/releases</url>
</repository>
<snapshotRepository>
<id>jzy3d-ftp</id>
<name>Jzy3d Maven Folder SNAPSHOTS</name>
<url>ftp://ftp.cluster013.ovh.net/maven/snapshots</url>
</snapshotRepository>
</distributionManagement>
<repositories>
<repository>
<id>jzy3d-snapshots</id>
<name>Jzy3d Snapshots</name>
<url>http://maven.jzy3d.org/snapshots</url>
</repository>
<repository>
<id>jzy3d-releases</id>
<name>Jzy3d Snapshots</name>
<url>http://maven.jzy3d.org/releases</url>
</repository>
</repositories>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.10.3</version>
<configuration>
<stylesheetfile>jzy3d-api/doc/layout.css</stylesheetfile>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.10</version>
<executions>
<execution>
<id>copy</id>
<phase>package</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>[ groupId ]</groupId>
<artifactId>[ artifactId ]</artifactId>
<version>[ version ]</version>
<type>[ packaging ]</type>
<classifier> [classifier - optional] </classifier>
<overWrite>[ true or false ]</overWrite>
<outputDirectory>[ output directory ]</outputDirectory>
<destFileName>[ filename ]</destFileName>
</artifactItem>
</artifactItems>
<!-- other configurations here -->
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
<extensions>
<extension>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-ftp</artifactId>
<version>${version.mvn.ftp}</version>
</extension>
</extensions>
</build>
</project>
并且错误消息保持 运行 (jzy3d-jdt-core) 的子 POM 是:
<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>
<groupId>org.jzy3d</groupId>
<artifactId>jzy3d-master</artifactId>
<version>0.9.2-SNAPSHOT</version>
</parent>
<artifactId>jzy3d-jdt-core</artifactId>
<name>JDT core (fork of https://github.com/yonatang/JDT)</name>
<description>Java Delaunay Triangulation Core Library</description>
<properties>
<testng.version>6.5.2</testng.version>
<hamcrest.version>1.3.RC2</hamcrest.version>
</properties>
<dependencies>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.3</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.1</version>
</dependency>
测试失败是在实施测试时做出的断言的负面结果。您基本上会从调用的方法或您正在阅读的字段中得到意想不到的结果。
-> 它坏了,必须修好。这并不意味着您必须修复它。
mvn package -Dmaven.test.skip=true
可能有助于构建资源。
但是您可以下载二进制文件而不是自己构建源代码。这些似乎也可以在网页上找到。
当我 运行 mvn package -e
在 jzy3d 的 master 或 0.9.1 分支的新克隆上时,所有测试都通过并且 Maven 构建成功。
从上面的输出来看,src/test/java/il/ac/idc/jdt/SmokeTest.java
(在 jzy3d-jdt-core
子模块中)中的 shouldRunOnExampleData
测试对您来说失败了。查看该测试的源代码,很明显它是为 运行 在某种 Unix 风格上设计的,因为它引用了硬编码路径 "/inputs/"
和 "/outputs/"
.
另外,从您上面的输出来看,很明显您 运行 喜欢某种风格 Windows,因此您没有通过测试也就不足为奇了。如果你想让测试通过,你可以将它们分别更改为 "\inputs\"
和 "\outputs\"
,或者使用 应该 更灵活的 File.separator
为每个 OS.
工作
如果您不关心测试是否通过,而只想构建由 mvn package -e
生成的 jar 文件,那么您可以 运行 mvn package -e -DskipTests
。 (设置 -Dmaven.test.skip=true
也应该有效;请参阅 Maven documentation on skipping tests。)
To simplify what I'm asking: what is a test failure and how do I rectify it?
在构建 Maven 项目期间,它会自动执行所谓的 unit tests。这些是 Java classes,其目的是验证项目特定方法的行为。在这种情况下,事实证明其中一个测试在您的构建中失败了。
2016 年 3 月 12 日更新:post 中提到的问题已修复!
当运行在Windows时,jzy3d库的测试确实有问题。我查了他们的master GitHub 和你一样的错误
原因是,在单元测试期间,库正在检查两个文件的内容是否相等。但是,创建一个文件时使用当前OS的行分隔符,而控制文件使用Unix行分隔符
如果您查看文件 jzy3d-jdt-core\src\test\resources\outputs\t1_1000.tsin_result.tsin
,您会注意到它使用了 Unix \n
行分隔符。失败的 shouldRunOnExampleData
测试正在创建一个临时文件来验证该控制文件。在我的 Windows 机器上,这个临时文件是在 C:\Users\{UserName}\AppData\Local\Temp\jdt-4971059362436436156.smf
中创建的,如果打开,您可以看到它使用 Windows 行分隔符 \r\n
。因此,这两个文件不相等,测试失败。
针对该库的开发人员的一个可能的解决方案是在测试 shouldRunOnExampleData
中使用 IOUtils.contentEqualsIgnoreEOL
,因为此方法在比较两个输入流时不检查行尾。我创建了 the issue 52 for this problem and submitted a pull request,现在已合并并关闭。
图书馆用户的解决方案是:
- 用Windows行分隔符更改
jzy3d-jdt-core\src\test\resources\outputs
中每个文件的行尾。如果您使用 Notepad++ 打开文件,您可以通过转到 "Edit > EOL Conversion > Windows format" 并保存文件来简单地更改 line-endings。
- 通过在 class
SmokeTest
中使用 contentEqualsIgnoreEOL
来修复代码(参数然后需要用 InputStreamReader
包装)。
- 使用
mvn clean install -DskipTests=true
跳过测试。
就我而言,我更改了测试代码以忽略行尾。构建的其余部分进行得很好。
为了简化我的问题:什么是测试失败以及如何纠正它?
我是 Maven 的新手,我正在尝试让图形绘图应用程序 Jzy3d 在我的计算机上运行。我已经将所有插件更新为父模块和子模块的 POM 文件中的最新版本,并检查 Maven 是否指向我安装的最新 JRE(确实如此)。
我的依赖树也很好,涵盖了我在这个论坛和其他地方看到这个错误的许多途径。
我根本无法隔离问题。
运行mvn package -e时报错信息如下:
D:\Program Files\jzy3d-api-master>mvn package -e
[INFO] Error stacktraces are turned on.
[INFO] Scanning for projects...
[INFO]
------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] Jzy3d Master Project
[INFO] JDT core (fork of https://github.com/yonatang/JDT)
[INFO] Jzy3d API
[INFO] Jzy3d SWT Tools
[INFO] Jzy3d Tutorials
[INFO]
[INFO]
------------------------------------------------------------------------
[INFO] Building Jzy3d Master Project 0.9.2-SNAPSHOT
[INFO]
------------------------------------------------------------------------
[INFO]
[INFO]
------------------------------------------------------------------------
[INFO] Building JDT core (fork of https://github.com/yonatang/JDT)
0.9.2-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ jzy3d-jdt-core ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory D:\Program Files\jzy3d-api-master\jzy3d-jdt-core\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.3:compile (default-compile) @ jzy3d-jdt-core ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ jzy3d-jdt-core ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 18 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.3:testCompile (default-testCompile) @ jzy3d-jdt-core ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.19.1:test (default-test) @ jzy3d-jdt-core ---
[INFO] Surefire report directory: D:\Program Files\jzy3d-api-master\jzy3d-jdt-core\target\surefire-reports
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running il.ac.idc.jdt.SmokeTest Configuring TestNG with: TestNG60Configurator Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 2.639 sec <<< FAILURE! - in il.ac.idc.jdt.SmokeTest shouldRunOnExampleData(il.ac.idc.jdt.SmokeTest) Time elapsed: 0.412 sec <<< FAILURE! java.lang.AssertionError: t1_1000.tsin trangulation is correct for smf
at il.ac.idc.jdt.SmokeTest.shouldRunOnExampleData(SmokeTest.java:28)
Results :
Failed tests: SmokeTest.shouldRunOnExampleData:28 t1_1000.tsin trangulation is correct for smf
Tests run: 1, Failures: 1, Errors: 0, Skipped: 0
[INFO]
------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] Jzy3d Master Project ............................... SUCCESS [ 0.022 s]
[INFO] JDT core (fork of https://github.com/yonatang/JDT) . FAILURE [ 8.853 s]
[INFO] Jzy3d API .......................................... SKIPPED
[INFO] Jzy3d SWT Tools .................................... SKIPPED
[INFO] Jzy3d Tutorials .................................... SKIPPED
[INFO]
------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO]
------------------------------------------------------------------------
[INFO] Total time: 9.772 s
[INFO] Finished at: 2016-01-13T11:56:26+00:00
[INFO] Final Memory: 8M/22M
[INFO]
------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.19.1:test (default-test) on project jzy3d-jdt-core: There are test failures.
[ERROR]
[ERROR] Please refer to D:\Program Files\jzy3d-api-master\jzy3d-jdt-core\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.19.1:test (default-test) on project jzy3d-jdt-core: There are test failures.
Please refer to D:\Program Files\jzy3d-api-master\jzy3d-jdt-core\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:128)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
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:\Program Files\jzy3d-api-master\jzy3d-jdt-core\target\surefire-reports for the individual test results.
at org.apache.maven.plugin.surefire.SurefireHelper.reportExecution(SurefireHelper.java:91)
at org.apache.maven.plugin.surefire.SurefirePlugin.handleSummary(SurefirePlugin.java:320)
at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeAfterPreconditionsChecked(AbstractSurefireMojo.java:892)
at org.apache.maven.plugin.surefire.AbstractSurefireMojo.execute(AbstractSurefireMojo.java:755)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
... 20 more [ERROR] [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 [ERROR] [ERROR] After correcting the problems, you can resume the build with the command [ERROR] mvn <goals> -rf :jzy3d-jdt-core
我的父 POM 文件是:
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.jzy3d</groupId>
<artifactId>jzy3d-master</artifactId>
<version>0.9.2-SNAPSHOT</version>
<packaging>pom</packaging>
<name>Jzy3d Master Project</name>
<url>http://www.jzy3d.org</url>
<description>A java API to draw 3d charts.</description>
<developers>
<developer>
<id>martin.pernollet</id>
<name>Martin Pernollet</name>
<email>martin@jzy3d.org</email>
<url>http://twitter.com/jzy3d</url>
</developer>
<developer>
<id>nils.hoffmann</id>
<name>Nils Hoffmann</name>
</developer>
<developer>
<id>juan.barandiaran</id>
<name>Juan Barandiaran</name>
</developer>
</developers>
<licenses>
<license>
<name>The (New) BSD License</name>
<url>http://www.opensource.org/licenses/bsd-license.php</url>
<distribution>repo</distribution>
</license>
</licenses>
<scm>
<connection>scm:git:git://github.com/jzy3d/jzy3d-api</connection>
</scm>
<issueManagement>
<system>Github</system>
<url>https://github.com/jzy3d/jzy3d-api/issues</url>
</issueManagement>
<modules>
<module>jzy3d-api</module>
<!-- <module>jzy3d-javafx</module> -->
<module>jzy3d-swt</module>
<module>jzy3d-jdt-core</module>
<module>jzy3d-tutorials</module>
</modules>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<version.jzy3d>0.9.2-SNAPSHOT</version.jzy3d>
<version.java.source>1.6</version.java.source>
<version.java.target>1.6</version.java.target>
<version.mvn.compiler>3.0</version.mvn.compiler>
<version.mvn.ftp>1.0-beta-6</version.mvn.ftp>
<version.mvn.deploy>2.4</version.mvn.deploy>
<version.mvn.javadoc>2.9.1</version.mvn.javadoc>
<version.libs.junit>4.10</version.libs.junit>
<version.libs.swt>4.2.1</version.libs.swt>
</properties>
<distributionManagement>
<repository>
<id>jzy3d-ftp</id>
<name>Jzy3d Maven Folder</name>
<url>ftp://ftp.cluster013.ovh.net/maven/releases</url>
</repository>
<snapshotRepository>
<id>jzy3d-ftp</id>
<name>Jzy3d Maven Folder SNAPSHOTS</name>
<url>ftp://ftp.cluster013.ovh.net/maven/snapshots</url>
</snapshotRepository>
</distributionManagement>
<repositories>
<repository>
<id>jzy3d-snapshots</id>
<name>Jzy3d Snapshots</name>
<url>http://maven.jzy3d.org/snapshots</url>
</repository>
<repository>
<id>jzy3d-releases</id>
<name>Jzy3d Snapshots</name>
<url>http://maven.jzy3d.org/releases</url>
</repository>
</repositories>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.10.3</version>
<configuration>
<stylesheetfile>jzy3d-api/doc/layout.css</stylesheetfile>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.10</version>
<executions>
<execution>
<id>copy</id>
<phase>package</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>[ groupId ]</groupId>
<artifactId>[ artifactId ]</artifactId>
<version>[ version ]</version>
<type>[ packaging ]</type>
<classifier> [classifier - optional] </classifier>
<overWrite>[ true or false ]</overWrite>
<outputDirectory>[ output directory ]</outputDirectory>
<destFileName>[ filename ]</destFileName>
</artifactItem>
</artifactItems>
<!-- other configurations here -->
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
<extensions>
<extension>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-ftp</artifactId>
<version>${version.mvn.ftp}</version>
</extension>
</extensions>
</build>
</project>
并且错误消息保持 运行 (jzy3d-jdt-core) 的子 POM 是:
<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>
<groupId>org.jzy3d</groupId>
<artifactId>jzy3d-master</artifactId>
<version>0.9.2-SNAPSHOT</version>
</parent>
<artifactId>jzy3d-jdt-core</artifactId>
<name>JDT core (fork of https://github.com/yonatang/JDT)</name>
<description>Java Delaunay Triangulation Core Library</description>
<properties>
<testng.version>6.5.2</testng.version>
<hamcrest.version>1.3.RC2</hamcrest.version>
</properties>
<dependencies>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.3</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.1</version>
</dependency>
测试失败是在实施测试时做出的断言的负面结果。您基本上会从调用的方法或您正在阅读的字段中得到意想不到的结果。
-> 它坏了,必须修好。这并不意味着您必须修复它。
mvn package -Dmaven.test.skip=true
可能有助于构建资源。
但是您可以下载二进制文件而不是自己构建源代码。这些似乎也可以在网页上找到。
当我 运行 mvn package -e
在 jzy3d 的 master 或 0.9.1 分支的新克隆上时,所有测试都通过并且 Maven 构建成功。
从上面的输出来看,src/test/java/il/ac/idc/jdt/SmokeTest.java
(在 jzy3d-jdt-core
子模块中)中的 shouldRunOnExampleData
测试对您来说失败了。查看该测试的源代码,很明显它是为 运行 在某种 Unix 风格上设计的,因为它引用了硬编码路径 "/inputs/"
和 "/outputs/"
.
另外,从您上面的输出来看,很明显您 运行 喜欢某种风格 Windows,因此您没有通过测试也就不足为奇了。如果你想让测试通过,你可以将它们分别更改为 "\inputs\"
和 "\outputs\"
,或者使用 应该 更灵活的 File.separator
为每个 OS.
如果您不关心测试是否通过,而只想构建由 mvn package -e
生成的 jar 文件,那么您可以 运行 mvn package -e -DskipTests
。 (设置 -Dmaven.test.skip=true
也应该有效;请参阅 Maven documentation on skipping tests。)
To simplify what I'm asking: what is a test failure and how do I rectify it?
在构建 Maven 项目期间,它会自动执行所谓的 unit tests。这些是 Java classes,其目的是验证项目特定方法的行为。在这种情况下,事实证明其中一个测试在您的构建中失败了。
2016 年 3 月 12 日更新:post 中提到的问题已修复!
当运行在Windows时,jzy3d库的测试确实有问题。我查了他们的master GitHub 和你一样的错误
原因是,在单元测试期间,库正在检查两个文件的内容是否相等。但是,创建一个文件时使用当前OS的行分隔符,而控制文件使用Unix行分隔符
如果您查看文件 jzy3d-jdt-core\src\test\resources\outputs\t1_1000.tsin_result.tsin
,您会注意到它使用了 Unix \n
行分隔符。失败的 shouldRunOnExampleData
测试正在创建一个临时文件来验证该控制文件。在我的 Windows 机器上,这个临时文件是在 C:\Users\{UserName}\AppData\Local\Temp\jdt-4971059362436436156.smf
中创建的,如果打开,您可以看到它使用 Windows 行分隔符 \r\n
。因此,这两个文件不相等,测试失败。
针对该库的开发人员的一个可能的解决方案是在测试 shouldRunOnExampleData
中使用 IOUtils.contentEqualsIgnoreEOL
,因为此方法在比较两个输入流时不检查行尾。我创建了 the issue 52 for this problem and submitted a pull request,现在已合并并关闭。
图书馆用户的解决方案是:
- 用Windows行分隔符更改
jzy3d-jdt-core\src\test\resources\outputs
中每个文件的行尾。如果您使用 Notepad++ 打开文件,您可以通过转到 "Edit > EOL Conversion > Windows format" 并保存文件来简单地更改 line-endings。 - 通过在 class
SmokeTest
中使用contentEqualsIgnoreEOL
来修复代码(参数然后需要用InputStreamReader
包装)。 - 使用
mvn clean install -DskipTests=true
跳过测试。
就我而言,我更改了测试代码以忽略行尾。构建的其余部分进行得很好。