Skip to main content
Version: 8.0.x

Running Individual Tests

When you debug issues, we recommend executing a specific test through Maven on the command line to save time and for convenience. This topic describes how to use commands to run and remotely debug single unit tests or integration tests.

note

All commands in the examples open remote debugging on port 8000.

Surefire Unit Tests​

The Maven Surefire plugin is used to run unit tests of an application. For more information, see the Maven Surefire Plugin documentation.

Running a single test​

To run a single test using the Maven Surefire plugin, use the following command:

mvn test -Dtest=<TEST_CLASS_NAME#TEST_METHOD_NAME>

Debugging a single test​

To debug a single test using the Maven Surefire plugin, use the following command:

mvn test -Dmaven.surefire.debug="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 -Xnoagent -Djava.compiler=NONE" -Dtest=<TEST_CLASS_NAME#TEST_METHOD_NAME>

Failsafe Integration Tests​

The Maven Failsafe plugin is used to run integration tests. For more information, see the Maven Failsafe Plugin documentation.

Running a single integration test​

To run a single Maven Failsafe plugin integration test, use the following command:

mvn verify -Dit.test=<TEST_CLASS_NAME#TEST_METHOD_NAME>

Debugging a single integration test​

To debug a single Maven Failsafe plugin integration test, use the following command:

mvn verify -Dmaven.failsafe.debug="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 -Xnoagent -Djava.compiler=NONE" -Dit.test=<TEST_CLASS_NAME#TEST_METHOD_NAME>

Failsafe Cucumber Tests​

The Maven Failsafe plugin also supports using Cucumber.

Running a single Cucumber test​

To run a single Cucumber test, use the following command:

mvn verify -Dcucumber.options="src/test/cucumber/com/elasticpath/cucumber/<FEATURE_FILENAME>"

Debugging a single Cucumber test​

To debug a single Cucumber test, use the following command:

mvn verify -Dmaven.failsafe.debug="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 -Xnoagent -Djava.compiler=NONE" -Dcucumber.options="src/test/cucumber/com/elasticpath/cucumber/<FEATURE_FILENAME>"

Failsafe Selenium Tests​

The Maven Failsafe plugin also supports using Selenium.

  1. Start the Selenium standalone Chrome docker image:

    docker run -d \
    -p 4444:4444 \
    -p 5900:5900 \
    -e SCREEN_WIDTH=1920 \
    -e SCREEN_HEIGHT=1080 \
    -e SCREEN_DEPTH=24 \
    --shm-size=2g \
    selenium/standalone-chrome-debug:3.141.59-20200525
  2. Start ActiveMQ, Cortex, Search, and Commerce Manager locally.

    note

    Use the following command to start Commerce Manager:

    mvn clean tomcat8:run-war -Dorg.eclipse.rap.rwt.enableUITests=true

Running a single Selenium test​

To run a single Selenium test, change to your extensions/cm/ext-cm-modules/system-tests/selenium folder and use the following command:

mvn verify -Dselenium.session.browser=remote_chrome \
-Dremote.web.driver.url=http://localhost:4444/wd/hub \
-Dselenium.session.baseurl=http://host.docker.internal:8081/cm \
-Dcucumber.options="src/test/resources/com.elasticpath.cucumber/<FEATURE_FILENAME>"

Debugging a single Selenium test​

To debug a single Selenium test, change to your extensions/cm/ext-cm-modules/system-tests/selenium folder and use the following command:

mvn verify -Dselenium.session.browser=remote_chrome \
-Dremote.web.driver.url=http://localhost:4444/wd/hub \
-Dselenium.session.baseurl=http://host.docker.internal:8081/cm \
-Dmaven.failsafe.debug="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 -Xnoagent -Djava.compiler=NONE" \
-Dcucumber.options="src/test/cucumber/com/elasticpath/cucumber/<FEATURE_FILENAME>"

To see why a test is failing, you can connect to the Selenium Docker host using Virtual Network Computing (VNC):

  • Host: localhost:5900
  • Password: secret