0

I'm in the process of converting my Java Maven repository from Junit 4 to Junit 5. After updating my methods, runner, and POM, I can run the tests locally in Intellij, but when running them on AWS Codebuild, the tests aren't run. I am using Cucumber alongside this.

RunTests.java

package com.eacautomation;

import io.cucumber.junit.platform.engine.Constants;
import org.junit.platform.suite.api.*;

@Suite(failIfNoTests = false)
@IncludeEngines("cucumber")
@SelectClasspathResource("FeatureFiles")
@SelectPackages("com.eacautomation")
@ConfigurationParameter(key = Constants.GLUE_PROPERTY_NAME, value = "com.eacautomation.stepDefinitions")
@ConfigurationParameter(key = Constants.PLUGIN_PROPERTY_NAME, value = "pretty")
@ConfigurationParameter(key = Constants.PLUGIN_PROPERTY_NAME, value = "junit:target/TEST-com.eacautomation.apiDefinition.RunCukesTest.xml")
@ConfigurationParameter(key = Constants.PLUGIN_PROPERTY_NAME, value = "html:target/cucumber-report/cucumber.html")
@ConfigurationParameter(key = Constants.PLUGIN_PROPERTY_NAME, value = "json:target/cucumber-report/cucumber.json")

public class RunTests {
}

pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<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>com.eacautomation</groupId>
    <artifactId>com.eacautomation</artifactId>
    <version>1.0-SNAPSHOT</version>
    <name>com.eacautomation</name>
    <description>com.eacautomation</description>

    <properties>
        <aws.java.sdk.version>1.12.788</aws.java.sdk.version>
        <commons.codec.version>1.19.0</commons.codec.version>
        <commons.lang3.version>3.18.0</commons.lang3.version>
        <cucumber.version>7.28.0</cucumber.version>
        <cucumber.html.version>0.2.7</cucumber.html.version>
        <cucumber.jvm.deps.version>1.0.6</cucumber.jvm.deps.version>
        <cucumber.picocontainer.version>7.28.1</cucumber.picocontainer.version>
        <extentreports.version>5.1.2</extentreports.version>
        <extentreports.cucumber7.adapter.version>1.14.0</extentreports.cucumber7.adapter.version>
        <gherkin.version>34.0.0</gherkin.version>
        <gherkin.jvm.deps.version.plugin>1.0.6</gherkin.jvm.deps.version.plugin>
        <googleauth.version>1.5.0</googleauth.version>
        <gson.version>2.13.1</gson.version>
        <guava.version>33.4.8-jre</guava.version>
        <hamcrest.all.version>1.3</hamcrest.all.version>
        <hamcrest.date.version>2.0.8</hamcrest.date.version>
        <httpclient.version>5.5</httpclient.version>
        <jackson.version>2.20</jackson.version>
        <jackson.core.version>2.20.0</jackson.core.version>
        <jakarta.xml.bind.version>4.0.2</jakarta.xml.bind.version>
        <javafaker.version>1.0.2</javafaker.version>
        <jaxb.runtime.version>4.0.5</jaxb.runtime.version>
        <json.smart.version>2.6.0</json.smart.version>
        <json.path.version>2.9.0</json.path.version>
        <json.simple.version>1.1.1</json.simple.version>
        <json.version>20250517</json.version>
        <junit.jupiter.version>5.13.4</junit.jupiter.version>
        <junit.platform.version>1.13.4</junit.platform.version>
        <junit.xml.formatter.version>0.8.1</junit.xml.formatter.version>
        <log4j.version>2.25.1</log4j.version>
        <maven.assembly.plugin.version>3.7.1</maven.assembly.plugin.version>
        <maven.clean.version>3.5.0</maven.clean.version>
        <maven.compiler.target>21</maven.compiler.target>
        <maven.compiler.source>21</maven.compiler.source>
        <maven.compiler.plugin.version>3.13.0</maven.compiler.plugin.version>
        <maven.cucumber.reporting.version>5.9.0</maven.cucumber.reporting.version>
        <maven.javadoc.plugin.version>3.11.2</maven.javadoc.plugin.version>
        <maven.jxr.plugin.version>3.6.0</maven.jxr.plugin.version>
        <maven.site.plugin.version>4.0.0-M16</maven.site.plugin.version>
        <maven.surefire.plugin.version>3.5.3</maven.surefire.plugin.version>
        <netty.codec.version>4.2.5.Final</netty.codec.version>
        <okhttp.version>4.12.0</okhttp.version>
        <poi.ooxml.version>5.4.1</poi.ooxml.version>
        <reporting.plugin.version>5.0.0</reporting.plugin.version>
        <restassured.version>5.5.5</restassured.version>
        <selenium.version>4.34.0</selenium.version>
        <selenium.grid.version>4.34.0</selenium.grid.version>
        <snappy.version>0.5</snappy.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>com.amazonaws</groupId>
            <artifactId>aws-java-sdk</artifactId>
            <version>${aws.java.sdk.version}</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/commons-codec/commons-codec -->
        <dependency>
            <groupId>commons-codec</groupId>
            <artifactId>commons-codec</artifactId>
            <version>${commons.codec.version}</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.apache.commons/commons-lang3 -->
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
            <version>${commons.lang3.version}</version>
        </dependency>
        <dependency>
            <groupId>io.cucumber</groupId>
            <artifactId>cucumber-core</artifactId>
            <version>${cucumber.version}</version>
        </dependency>
        <dependency>
            <groupId>io.cucumber</groupId>
            <artifactId>cucumber-java</artifactId>
            <version>${cucumber.version}</version>
        </dependency>
        <dependency>
            <groupId>io.cucumber</groupId>
            <artifactId>cucumber-junit</artifactId>
            <version>${cucumber.version}</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/io.cucumber/cucumber-junit-platform-engine -->
        <dependency>
            <groupId>io.cucumber</groupId>
            <artifactId>cucumber-junit-platform-engine</artifactId>
            <version>${cucumber.version}</version>
            <scope>test</scope>
        </dependency>
        <!-- https://mvnrepository.com/artifact/io.cucumber/cucumber-picocontainer -->
        <dependency>
            <groupId>io.cucumber</groupId>
            <artifactId>cucumber-picocontainer</artifactId>
            <version>${cucumber.picocontainer.version}</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/com.aventstack/extentreports -->
        <dependency>
            <groupId>com.aventstack</groupId>
            <artifactId>extentreports</artifactId>
            <version>${extentreports.version}</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/tech.grasshopper/extentreports-cucumber7-adapter -->
        <dependency>
            <groupId>tech.grasshopper</groupId>
            <artifactId>extentreports-cucumber7-adapter</artifactId>
            <version>${extentreports.cucumber7.adapter.version}</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/io.cucumber/gherkin -->
        <dependency>
            <groupId>io.cucumber</groupId>
            <artifactId>gherkin</artifactId>
            <version>${gherkin.version}</version>
        </dependency>
        <dependency>
            <groupId>com.warrenstrange</groupId>
            <artifactId>googleauth</artifactId>
            <version>${googleauth.version}</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.apache.httpcomponents.client5/httpclient5 -->
        <dependency>
            <groupId>org.apache.httpcomponents.client5</groupId>
            <artifactId>httpclient5</artifactId>
            <version>${httpclient.version}</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-annotations -->
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-annotations</artifactId>
            <version>${jackson.version}</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-core -->
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-core</artifactId>
            <version>${jackson.core.version}</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind -->
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
            <version>${jackson.core.version}</version>
        </dependency>
        <!-- API, java.xml.bind module -->
        <dependency>
            <groupId>jakarta.xml.bind</groupId>
            <artifactId>jakarta.xml.bind-api</artifactId>
            <version>${jakarta.xml.bind.version}</version>
        </dependency>
        <dependency>
            <groupId>com.github.javafaker</groupId>
            <artifactId>javafaker</artifactId>
            <version>${javafaker.version}</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/net.minidev/json-smart -->
        <dependency>
            <groupId>net.minidev</groupId>
            <artifactId>json-smart</artifactId>
            <version>${json.smart.version}</version>
        </dependency>
        <!-- Runtime, com.sun.xml.bind module -->
        <dependency>
            <groupId>org.glassfish.jaxb</groupId>
            <artifactId>jaxb-runtime</artifactId>
            <version>${jaxb.runtime.version}</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/com.jayway.jsonpath/json-path -->
        <dependency>
            <groupId>com.jayway.jsonpath</groupId>
            <artifactId>json-path</artifactId>
            <version>${json.path.version}</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/com.jayway.jsonpath/json-path-assert -->
        <dependency>
            <groupId>com.jayway.jsonpath</groupId>
            <artifactId>json-path-assert</artifactId>
            <version>${json.path.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-api</artifactId>
            <version>${junit.jupiter.version}</version>
            <scope>test</scope>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-engine -->
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-engine</artifactId>
            <version>${junit.jupiter.version}</version>
            <scope>test</scope>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.junit.platform/junit-platform-commons -->
        <dependency>
            <groupId>org.junit.platform</groupId>
            <artifactId>junit-platform-commons</artifactId>
            <version>${junit.platform.version}</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.junit.platform/junit-platform-console -->
        <dependency>
            <groupId>org.junit.platform</groupId>
            <artifactId>junit-platform-console</artifactId>
            <version>${junit.platform.version}</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.junit.platform/junit-platform-engine -->
        <dependency>
            <groupId>org.junit.platform</groupId>
            <artifactId>junit-platform-engine</artifactId>
            <version>${junit.platform.version}</version>
            <scope>test</scope>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.junit.platform/junit-platform-launcher -->
        <dependency>
            <groupId>org.junit.platform</groupId>
            <artifactId>junit-platform-launcher</artifactId>
            <version>${junit.platform.version}</version>
            <scope>test</scope>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.junit.platform/junit-platform-runner -->
        <dependency>
            <groupId>org.junit.platform</groupId>
            <artifactId>junit-platform-runner</artifactId>
            <version>${junit.platform.version}</version>
            <scope>test</scope>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.junit.platform/junit-platform-suite-api -->
        <dependency>
            <groupId>org.junit.platform</groupId>
            <artifactId>junit-platform-suite-api</artifactId>
            <version>${junit.platform.version}</version>
            <scope>test</scope>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.junit.platform/junit-platform-suite-engine -->
        <dependency>
            <groupId>org.junit.platform</groupId>
            <artifactId>junit-platform-suite-engine</artifactId>
            <version>${junit.platform.version}</version>
            <scope>test</scope>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.junit.vintage/junit-vintage-engine -->
        <dependency>
            <groupId>org.junit.vintage</groupId>
            <artifactId>junit-vintage-engine</artifactId>
            <version>${junit.jupiter.version}</version>
            <scope>test</scope>
        </dependency>
        <!-- https://mvnrepository.com/artifact/io.cucumber/junit-xml-formatter -->
        <dependency>
            <groupId>io.cucumber</groupId>
            <artifactId>junit-xml-formatter</artifactId>
            <version>${junit.xml.formatter.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-api</artifactId>
            <version>${log4j.version}</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-core -->
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-core</artifactId>
            <version>${log4j.version}</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-jpl -->
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-jpl</artifactId>
            <version>${log4j.version}</version>
            <scope>runtime</scope>
        </dependency>
        <!-- https://mvnrepository.com/artifact/com.squareup.okhttp3/logging-interceptor -->
        <dependency>
            <groupId>com.squareup.okhttp3</groupId>
            <artifactId>logging-interceptor</artifactId>
            <version>${okhttp.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-assembly-plugin</artifactId>
            <version>${maven.assembly.plugin.version}</version>
        </dependency>
        <dependency>
            <groupId>net.masterthought</groupId>
            <artifactId>maven-cucumber-reporting</artifactId>
            <version>${maven.cucumber.reporting.version}</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-failsafe-plugin -->
        <dependency>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-failsafe-plugin</artifactId>
            <version>${maven.surefire.plugin.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>${maven.surefire.plugin.version}</version>
            <type>maven-plugin</type>
        </dependency>
        <!-- https://mvnrepository.com/artifact/io.netty/netty-codec -->
        <dependency>
            <groupId>io.netty</groupId>
            <artifactId>netty-codec</artifactId>
            <version>${netty.codec.version}</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/io.netty/netty-codec-http -->
        <dependency>
            <groupId>io.netty</groupId>
            <artifactId>netty-codec-http</artifactId>
            <version>${netty.codec.version}</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/com.squareup.okhttp3/okhttp -->
        <dependency>
            <groupId>com.squareup.okhttp3</groupId>
            <artifactId>okhttp</artifactId>
            <version>${okhttp.version}</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.apache.poi/poi-ooxml -->
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi-ooxml</artifactId>
            <version>${poi.ooxml.version}</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/de.monochromata.cucumber/reporting-plugin -->
        <dependency>
            <groupId>de.monochromata.cucumber</groupId>
            <artifactId>reporting-plugin</artifactId>
            <version>${reporting.plugin.version}</version>
        </dependency>
        <dependency>
            <groupId>io.rest-assured</groupId>
            <artifactId>rest-assured</artifactId>
            <version>${restassured.version}</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.iq80.snappy/snappy -->
        <dependency>
            <groupId>org.iq80.snappy</groupId>
            <artifactId>snappy</artifactId>
            <version>${snappy.version}</version>
        </dependency>
    </dependencies>

    <repositories>
        <repository>
            <id>repo.bodar.com</id>
            <url>https://repo.bodar.com</url>
        </repository>
    </repositories>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>${maven.compiler.plugin.version}</version>
                <configuration>
                    <source>${maven.compiler.source}</source>
                    <target>${maven.compiler.target}</target>
                    <encoding>UTF-8</encoding>
                    <compilerArgs>
                        <arg>-parameters</arg>
                    </compilerArgs>
                </configuration>
            </plugin>
            <plugin>
                <groupId>net.masterthought</groupId>
                <artifactId>maven-cucumber-reporting</artifactId>
                <version>${maven.cucumber.reporting.version}</version>
                <executions>
                    <execution>
                        <id>execution</id>
                        <phase>verify</phase>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                        <configuration>
                            <projectName>analysis-ui-test</projectName>
                            <outputDirectory>${project.build.directory}/cucumber-html-reports
                            </outputDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-report-plugin</artifactId>
                <version>${maven.surefire.plugin.version}</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-site-plugin</artifactId>
                <version>${maven.site.plugin.version}</version>
                <configuration>
                    <outputDirectory>${project.build.directory}/surefire-report</outputDirectory>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>${maven.surefire.plugin.version}</version>
                <dependencies>
                    <dependency>
                        <groupId>org.junit.jupiter</groupId>
                        <artifactId>junit-jupiter</artifactId>
                        <version>${junit.jupiter.version}</version>
                    </dependency>
                </dependencies>
                <configuration>
                    <includes>
                        <include>**/RunTests.java</include>
                    </includes>
                    <systemPropertyVariables>
                        <buildDirectory>${project.build.directory}</buildDirectory>
                    </systemPropertyVariables>
<!--                    <argLine>-->
<!--                        &#45;&#45;add-opens java.base/java.lang=ALL-UNNAMED-->
<!--                        &#45;&#45;add-opens java.base/java.util=ALL-UNNAMED-->
<!--                        &#45;&#45;add-opens java.base/java.lang.reflect=ALL-UNNAMED-->
<!--                        &#45;&#45;add-opens java.base/java.text=ALL-UNNAMED-->
<!--                        &#45;&#45;add-opens java.desktop/java.awt.font=ALL-UNNAMED-->
<!--                    </argLine>-->
                    <rerunFailingTestsCount>1</rerunFailingTestsCount>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <reporting>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-report-plugin</artifactId>
                <version>${maven.surefire.plugin.version}</version>
            </plugin>
        </plugins>
    </reporting>

</project>

and this is the buildspec.yml file I am using to run on AWS Codebuild:

version: 0.2

phases:
  install:
    runtime-versions:
      java: corretto21
    commands:
      - echo Install started on `date`
      - java --version
  build:
    commands:
      - echo Build started on `date`
      - mvn $STAGING_CREDENTIALS -Dcucumber.filter.tags="@Regression" -Dsurefire.rerunFailingTestsCount=1 test
  post_build:
    commands:
      - echo Build completed on `date`
      - mvn surefire-report:report-only
reports:
  arn:aws:codebuild:eu-west-2:161668806093:report-group/eac-staging-daily-test-reportGroupCucumberJson:
    files:
      - 'TEST-com.eacautomation.apiDefinition.RunCukesTest.xml'
    base-directory: 'target'
    discard-paths: yes
artifacts:
  files:
    - '**/*'
cache:
  paths:
    - '/root/.m2/**/*'

When running on AWS Codebuild, this is the response:

[INFO] 
[INFO] -------------------------------------------------------
[INFO]  T E S T S
[INFO] -------------------------------------------------------
2025-09-10T12:59:37.517165138Z main INFO Starting configuration XmlConfiguration[location=/codebuild/output/src1681936737/src/git-codecommit.eu-west-2.amazonaws.com/v1/repos/eacautomation/target/test-classes/log4j2.xml, lastModified=2025-09-10T12:59:29.481Z]...
2025-09-10T12:59:37.519017025Z main INFO Configuration XmlConfiguration[location=/codebuild/output/src1681936737/src/git-codecommit.eu-west-2.amazonaws.com/v1/repos/eacautomation/target/test-classes/log4j2.xml, lastModified=2025-09-10T12:59:29.481Z] started.
2025-09-10T12:59:37.521663977Z main INFO Stopping configuration org.apache.logging.log4j.core.config.DefaultConfiguration@783a467b...
2025-09-10T12:59:37.522152207Z main INFO Configuration org.apache.logging.log4j.core.config.DefaultConfiguration@783a467b stopped.
[INFO] 
[INFO] Results:
[INFO] 
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
[INFO] 
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  02:44 min
[INFO] Finished at: 2025-09-10T12:59:37Z
[INFO] ------------------------------------------------------------------------

[Container] 2025/09/10 12:59:37.586760 Phase complete: BUILD State: SUCCEEDED
2

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.