Amit Rai
Amit Rai

Reputation: 1

Surefire plugin fails forking as CMD.exe is restrcited in my system

I am using maven-fail-safe plugin and maven-surefire-plugin to run my tests. but surefire plugin calls cmd.exe for forking command line and fails to execute the goals as cmd.exe is restricted to use in my organization.

Errors from Eclipse console ##

The forked VM terminated without properly saying goodbye. VM crash or System.exit called?

[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"

below is my 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>

Upvotes: 0

Views: 564

Answers (2)

Mihir
Mihir

Reputation: 511

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

I had a similar issue and doing this helped!

Upvotes: 0

Omprakash Gautam
Omprakash Gautam

Reputation: 167

Try setting the forkCount to 0

Upvotes: 1

Related Questions