Surefire 插件无法分叉,因为 CMD.exe 在我的系统中受到限制

问题描述 投票:0回答:2

我正在使用 maven-fail-safe 插件和 maven-surefire-plugin 来运行我的测试。 但 Surefire 插件调用 cmd.exe 来分叉命令行,但无法执行目标,因为 cmd.exe 仅限在我的组织中使用。

Eclipse 控制台出现错误##

分叉的虚拟机在没有正确告别的情况下终止了。 VM 崩溃或调用 System.exit?

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-failsafe- 
plugin:2.18.1:integration-test (default) on project bdd-test: Execution 
default of goal org.apache.maven.plugins:maven-failsafe- 
plugin:2.18.1:integration-test failed: 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\jre1.8.0_151\bin\java" -Xmx512m -jar C:\Users\ar11495\Serenity- 
workspace\bdd-test\target\surefire\surefirebooter3944168471238729169.jar 
C:\Users\ar11495\Serenity-workspace\bdd- 
test\target\surefire\surefire3290184423596544348tmp 
C:\Users\ar11495\Serenity-workspace\bdd- 
test\target\surefire\surefire_0917807971278197542tmp"

下面是我的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>firstSerenity</groupId>
    <artifactId>bdd-test</artifactId>
    <version>1.0</version>
    <packaging>jar</packaging>

    <name>Sample Serenity project using JBehave and WebDriver</name>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <serenity.version>1.8.21</serenity.version>
        <serenity.jbehave.version>1.34.0</serenity.jbehave.version>
        <webdriver.driver>firefox</webdriver.driver>
    </properties>

    <repositories>
        <repository>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
            <id>central</id>
            <name>bintray</name>
            <url>http://jcenter.bintray.com</url>
        </repository>
    </repositories>
    <pluginRepositories>
        <pluginRepository>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
            <id>central</id>
            <name>bintray-plugins</name>
            <url>http://jcenter.bintray.com</url>
        </pluginRepository>
    </pluginRepositories>

    <dependencies>


<dependency>
    <groupId>org.seleniumhq.selenium</groupId>
    <artifactId>selenium-java</artifactId>
    <version>2.53.1</version>
</dependency>

        <dependency>
            <groupId>net.serenity-bdd</groupId>
            <artifactId>serenity-core</artifactId>
            <version>${serenity.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>net.serenity-bdd</groupId>
            <artifactId>serenity-jbehave</artifactId>
            <version>${serenity.jbehave.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-simple</artifactId>
            <version>1.7.7</version>
        </dependency>


<dependency>
    <groupId>org.apache.poi</groupId>
    <artifactId>poi-ooxml</artifactId>
    <version>3.17</version>
</dependency> 

        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
            <scope>test</scope>
        </dependency>

    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.22.0</version>
                <configuration>
                    <skip>true</skip>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-failsafe-plugin</artifactId>
                <version>2.22.0</version>
                <configuration>

                    <includes>
                        <include>**/*Test.java</include>
                        <include>**/*TestSuite.java</include>
                        <include>**/Test*.java</include>
                        <include>**/When*.java</include>
                    </includes>
                    <argLine>-Xmx512m</argLine>
                    <systemPropertyVariables>
                        <webdriver.driver>${webdriver.driver}</webdriver.driver>
                    </systemPropertyVariables>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>integration-test</goal>
                            <goal>verify</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.2</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>net.serenity-bdd.maven.plugins</groupId>
                <artifactId>serenity-maven-plugin</artifactId>
                <version>1.8.21</version>
                <executions>
                    <execution>
                        <id>serenity-reports</id>
                        <phase>post-integration-test</phase>
                        <goals>
                            <goal>aggregate</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>
java maven-plugin maven-surefire-plugin serenity-bdd maven-failsafe-plugin
2个回答
1
投票

尝试将

forkCount
设置为
0


0
投票
<build>
  <plugins>
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-surefire-plugin</artifactId>
      <version>3.0.0-M7</version>
      <configuration>
        <forkCount>0</forkCount> <!-- Disable forking -->
      </configuration>
    </plugin>
  </plugins>
</build>

我遇到了类似的问题,这样做很有帮助!

© www.soinside.com 2019 - 2024. All rights reserved.