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="-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=8000" -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="-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=8000" -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="-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=8000" -Dcucumber.options="src/test/cucumber/com/elasticpath/cucumber/<FEATURE_FILENAME>"
Failsafe Selenium Tests
The Maven Failsafe plugin also supports using Selenium.
Start the Selenium standalone Chrome docker image:
docker run -d \ -p 4444:4444 \ -p 7900:7900 \ -e SCREEN_WIDTH=1920 \ -e SCREEN_HEIGHT=1080 \ -e SCREEN_DEPTH=24 \ --shm-size=2g \ selenium/standalone-chrome:latest
note
On a Mac M1 processor, replace
selenium/standalone-chrome:latest
withseleniarm/standalone-chromium:latest
in the command above.Start the following locally:
- ActiveMQ
- Cortex
- Search Server
- Batch Server
- Integration Server
- Commerce Manager
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 \
-Dep.export.cm.host=host.docker.internal \
-Dep.import.cm.host=host.docker.internal \
-Dexport.db.connection.host=localhost \
-Dexport.import.db.schemaname=<DB_SCHEMA> \
-Dexport.import.db.connection.username=<DB_USERNAME> \
-Dexport.import.db.connection.password=<DB_PASSWORD> \
-Dsearch.host.url=http://localhost:8082/searchserver \
-Dcucumber.options="src/test/resources/com.elasticpath.cucumber/<FEATURE_FILENAME>"
note
Make sure to replace the <DB_SCHEMA>
, <DB_USERNAME>
, and <DB_PASSWORD>
placeholders in the command above.
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 \
-Dep.export.cm.host=host.docker.internal \
-Dep.import.cm.host=host.docker.internal \
-Dexport.db.connection.host=localhost \
-Dexport.import.db.schemaname=<DB_SCHEMA> \
-Dexport.import.db.connection.username=<DB_USERNAME> \
-Dexport.import.db.connection.password=<DB_PASSWORD> \
-Dsearch.host.url=http://localhost:8082/searchserver \
-Dmaven.failsafe.debug="-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=8000" \
-Dcucumber.options="src/test/resources/com.elasticpath.cucumber/<FEATURE_FILENAME>"
note
Make sure to replace the <DB_SCHEMA>
, <DB_USERNAME>
, and <DB_PASSWORD>
placeholders in the command above.
View the running test
To see what is happening inside the container, connect to http://localhost:7900/?autoconnect=1&resize=scale&password=secret
.