I have below POM in my project.
mvn clean verify -P it
POM:
<build>
<pluginManagement>
<plugins>
.....
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-plugin.version}</version>
<configuration>
<skipTests>false</skipTests>
<excludes>
<exclude>**/*CucumberTests.java</exclude>
<exclude>**/IT*.java</exclude>
</excludes>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>${maven-plugin.version}</version>
<executions>
<execution>
<id>integration-tests</id>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
<configuration>
<skipTests>false</skipTests>
<testFailureIgnore>true</testFailureIgnore>
<excludes>
<exclude>none</exclude>
</excludes>
<includes>
<include>**/*CucumberTests.java</include>
<include>**/*IT.java</include>
</includes>
<systemPropertyVariables>
<it.server.port>${random.http.port}</it.server.port>
<it.jmx.port>${random.jmx.port}</it.jmx.port>
</systemPropertyVariables>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>1.5.9.RELEASE</version>
<executions>
<execution>
<id>pre-integration-test</id>
<goals>
<goal>start</goal>
</goals>
<configuration>
<skip>false</skip>
<wait>2000</wait>
<!-- Max retry count -->
<maxAttempts>180</maxAttempts>
<jmxPort>${random.jmx.port}</jmxPort>
<arguments>
<argument>--server.port=${random.http.port}</argument>
<argument>--spring.profiles.active=${spring.profile}</argument>
</arguments>
<jvmArguments>
-Djava.security.egd=file:///dev/urandom
</jvmArguments>
</configuration>
</execution>
<execution>
<id>post-integration-test</id>
<goals>
<goal>stop</goal>
</goals>
<configuration>
<skip>false</skip>
<jmxPort>${random.jmx.port}</jmxPort>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
<plugins>
...
</plugin>
</plugins>
</build>
Test class:
import org.junit.runner.RunWith;
import io.cucumber.junit.CucumberOptions;
import net.serenitybdd.cucumber.CucumberWithSerenity;
@RunWith(CucumberWithSerenity.class)
@CucumberOptions(
plugin = {"pretty"},
glue = {"my.stepdefinitions"},
tags = {"@Demo"},
features = "src/it/resources/features/"
)
public class MicroServiceCucumberTests {
}
path: src/it/java
Basically it trigger sure-fire and then startup the app and just stuck there without executing maven-failsafe-plugin:2.21.0:integration-test (integration-tests)
Versions are being used:
<serenity.plugin.version>2.4.34</serenity.plugin.version>
<serenity.version>2.4.34</serenity.version>
<serenity.cucumber.version>2.4.34</serenity.cucumber.version>
<cucumber.version>6.10.4</cucumber.version>
<maven-plugin.version>3.0.0-M5</maven-plugin.version>
<java.version>1.8</java.version>
After digging further into logs what I noticed was, app didn't start up properly and stuck with below logs
DEBUG] Application argument(s): --server.port=54110 --spring.profiles.active=it
[DEBUG] Connecting to local MBeanServer at port 54111
[DEBUG] Waiting for spring application to start...
[DEBUG] MBean server at port 54111 is not up yet...
[DEBUG] Spring application is not ready yet, waiting 2000ms (attempt 1)
[DEBUG] MBean server at port 54111 is not up yet...
[DEBUG] Spring application is not ready yet, waiting 2000ms (attempt 2)
This solution worked for me https://stackoverflow.com/a/65952986/2303693
Adding below within the spring-boot-maven-plugin in the POM did the trick.
<configuration>
<fork>false</fork>
</configuration>
However same code worked in iOS machine without above fix. Further still not sure what caused the issue in Windows.