Maven构建时的初始化错误

时间:2017-06-29 14:19:05

标签: maven unit-testing

我遇到的问题是,当我尝试构建项目时,它失败了:

Surefire report directory: C:\...

------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running com.energyict.projects.customer.coop.ems.exporters.ClassTestName
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.052 sec <<< FAILURE!
Running com.energyict.projects.customer.coop.ems.exporters.AnotherClassTestName
Tests run: 7, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.225 sec

Results :

Tests in error: 
  initializationError(path for class here)

Tests run: 8, Failures: 0, Errors: 1, Skipped: 0

[INFO] ------------------------------------------------------------------------
[ERROR] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] There are test failures.

当Maven尝试运行测试文件时会发生这种情况,但如果我运行任何单个测试 - 它运行正常。

为什么每个测试都能正常运行,但是当我尝试构建项目时,它会在测试中失败?

有人可以提出建议吗?

更新:添加了更多日志。

Please refer to 'class path'\trunk\target\surefire-reports for the individual test results.
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:715)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:556)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:535)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:387)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:348)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:180)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
    at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60)
    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:498)
    at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
    at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
    at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
    at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
    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:498)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)
Caused by: org.apache.maven.plugin.MojoFailureException: There are test failures.

Please refer to 'class path'\trunk\target\surefire-reports for the individual test results.
    at org.apache.maven.plugin.surefire.SurefirePlugin.execute(SurefirePlugin.java:575)
    at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:694)
    ... 22 more
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 15 seconds
[INFO] Finished at: Thu Jun 29 19:23:06 MSK 2017
[INFO] Final Memory: 74M/721M
[INFO] ------------------------------------------------------------------------

1 个答案:

答案 0 :(得分:0)

在构建项目时,maven将无法构建测试类,因此我们使用这样的命令来反编译测试类。

-e clean install -Dmaven.test.skip=true
相关问题