The Maven plugin has the following goals: The stopForked goal does assumes that MockServer is running on the same physical machine as it uses 127.0.0.1 to communicate with MockServer stop socket. To stop a forked instance of MockServer running on the same machine: mvn mockserver:stopForked To run MockServer asynchronously as a forked JVM: mvn mockserver:runForked To run MockServer synchronously and block: mvn mockserver:run The Maven plugin can also be used from the command line to start and stop MockServer, as follows:
Stop goals as these run MockServer on a separate thread that is stopped however maven exits (even if a test fails).Īlternatively a TestListener can be used with maven-surefire-plugin to ensure that MockServer is stopped even when a test fails, as follows: If you want to ensure MockServer is stopped even when there are test failures make sure you use start and Verify phase is not run if a test fails so the forked MockServer will not be stopped. If you use the runForked goal as above and the test phase fails (because a test has failed) MockServer will not be stopped as Maven does not run any more phases after a phase has failed. It is also possible to run MockServer as a forked JVM using the runForked and stopForked goals as follows: This ensures that any integration tests you run during the test or integration-test phases can use MockServer on the port specified. For more details about Maven build phases see: This will start MockServer during the process-test-classes phase and will stop MockServer during the verify phase. To run MockServer as part of your build add the following plugin to your pom.xml: MockServer has a UI that can be used to view the internal state within MockServer, including:
Run springs server for android web server code#
It is also possible to build and run MockServer directly from source code MockServer UI:
from the command line as a stand-alone process in a test environment.via a Helm chart in any Kubernetes environment.as a Docker container in any Docker enabled environment.using a Spring Test Execution Listener via a annotated test class.using a JUnit 5 Test Extension via a annotated JUnit 5 class.using a JUnit 4 via a annotated field in a JUnit 4 test.programmatically via a Java API in an or method.MockServer is flexible and support numerous usage patterns.