当前位置: 首页 > 知识库问答 >
问题:

Intellij-无法执行目标组织。阿帕奇。专家插件:maven surefire插件:2.22.2:项目***上的测试(默认测试):存在测试失败

子车飞鹏
2023-03-14

我有一个java maven项目,我使用JUnit Juniper为我的单元测试,而建设的项目,我得到下面的错误,如果我从我的本地构建相同的项目,它工作得非常好。

这是Intellij的问题吗?

我在Intellij中构建我的maven项目时面临以下问题,而当我从本地构建时,这个问题不会出现。

  • Intellij 2019.1.1
  • Maven版本#3.3.9
  • JDK#1.8

错误

Error Messages # [ERROR] The forked VM terminated without properly saying goodbye. VM crash or System.exit called?

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.22.2:test (default-test) on project ImplementJunit: There are test failures.
[ERROR] Please refer to dump files (if any exist) [date].dump, [date]-jvmRun[N].dump and [date].dumpstream.
[ERROR] The forked VM terminated without properly saying goodbye. VM crash or System.exit called?
[ERROR] Command was cmd.exe /X /C ""C:\Program Files\Java\jdk1.8.0_221\jre\bin\java" -jar C:\Users\mnayak6\AppData\Local\Temp\surefire2741322585113384847\surefirebooter6121148917405790398.jar C:\Users\mnayak6\AppData\Local\Temp\surefire2741322585113384847 2020-04-23T15-08-00_156-jvmRun1 surefire3485996048802854818tmp surefire_08080424484537241935tmp"
[ERROR] Process Exit Code: 0
[ERROR] org.apache.maven.surefire.booter.SurefireBooterForkException: The forked VM terminated without properly saying goodbye. VM crash or System.exit called?
[ERROR] Command was cmd.exe /X /C ""C:\Program Files\Java\jdk1.8.0_221\jre\bin\java" -jar C:\Users\mnayak6\AppData\Local\Temp\surefire2741322585113384847\surefirebooter6121148917405790398.jar C:\Users\mnayak6\AppData\Local\Temp\surefire2741322585113384847 2020-04-23T15-08-00_156-jvmRun1 surefire3485996048802854818tmp surefire_08080424484537241935tmp"
[ERROR] Process Exit Code: 0
[ERROR] at org.apache.maven.plugin.surefire.booterclient.ForkStarter.fork(ForkStarter.java:669)
[ERROR] at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:282)
[ERROR] at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:245)
[ERROR] at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeProvider(AbstractSurefireMojo.java:1183)
[ERROR] at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeAfterPreconditionsChecked(AbstractSurefireMojo.java:1011)
[ERROR] at org.apache.maven.plugin.surefire.AbstractSurefireMojo.execute(AbstractSurefireMojo.java:857)
[ERROR] at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
[ERROR] at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
[ERROR] at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
[ERROR] at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
[ERROR] at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
[ERROR] at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
[ERROR] at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
[ERROR] at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
[ERROR] at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
[ERROR] at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
[ERROR] at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
[ERROR] at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
[ERROR] at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
[ERROR] at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
[ERROR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[ERROR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[ERROR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[ERROR] at java.lang.reflect.Method.invoke(Method.java:498)
[ERROR] at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
[ERROR] at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
[ERROR] at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
[ERROR] at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
[ERROR] at org.codehaus.classworlds.Launcher.main(Launcher.java:47)

波姆。XML

<properties>
        <!-- https://maven.apache.org/general.html#encoding-warning -->
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
    </properties>

    <dependencies>
            <!-- ... -->
            <dependency>
                <groupId>org.junit.jupiter</groupId>
                <artifactId>junit-jupiter-api</artifactId>
                <version>5.4.0 </version>
                <scope>test</scope>
            </dependency>
            <dependency>
                <groupId>org.junit.jupiter</groupId>
                <artifactId>junit-jupiter-engine</artifactId>
                <version>5.4.0</version>
                <scope>test</scope>
            </dependency>
            <!-- ... -->

        <!-- ... -->
        <dependency>
            <groupId>org.junit.platform</groupId>
            <artifactId>junit-platform-surefire-provider</artifactId>
            <version>1.2.0</version>
        </dependency>

    </dependencies>

    <build>

        <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <executions>
                <execution>
                    <id>test-compile</id>
                    <goals>
                        <goal>testCompile</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.22.2</version>
                <dependencies>
                    <dependency>
                        <groupId>org.junit.platform</groupId>
                        <artifactId>junit-platform-surefire-provider</artifactId>
                        <version>1.2.0</version>
                    </dependency>
                </dependencies>
            </plugin>

        </plugins>

    </build>

测试等级:

@Test
public void testGetMidDate()
{
    ImplementJunit implementJunit = new ImplementJunit();

    System.out.println("calling testGetMidDate() ");

    String date = implementJunit.getMidDate("20200101", "20200103");

    String ExpectedDate = "20200102";
    assertEquals(ExpectedDate,date);
}

共有1个答案

傅和璧
2023-03-14

我在Eclipse/Maven/JDK1上转载了这个问题。8/SureFire插件。

决议:-

当我纠正了所有的运行测试后,问题就解决了。一旦所有测试都通过,错误就消失了。虽然这并没有说明问题的根本原因和确切解决方案,但我觉得这与surefire插件的默认设置有关,即在任何测试失败后跳过测试

 类似资料: