Run VirtServer From Maven

Applies to VirtServer 3.21.0, last modified on June 27, 2024

If you use Maven in your development environment, you can start virtual services (virtual APIs) on VirtServer from Maven. To do this, you command Maven to download and use VirtServer Maven in your project.

Requirements and limitations

  • To start virtual services on a VirtServer by using Maven, you need a .pom file that references the VirtServer Maven plugin. Here is an example:

  • You do not need to configure your environment in a special way to run virtual services. Any required dependencies will be handled by Maven.

  • You cannot work with JMS virtual services from Maven.

Run tests from Maven

To use the plugin in a Maven build, connect it to the Maven build phase. For example, if you connect it to the -Pint-tests phase:

mvn -Pint-tests -DvirtServer.userName=John -DvirtServer.password=Smith -Dvirtserver.port:8080 -DvirtPort=9090 clean install


‑Dvirtserver.userName The username. A user with this name must exist on VirtServer.
‑Dvirtserver.password The password of the user.
‑ VirtServer URL. This URL will be used for all virtual services you will start. You must specify the URL of the running VirtServer instance.
‑Dvirtserver.port The port used by VirtServer. This port is required to deploy virtual services, but not to work with them.
‑DvirtPort The port the virtual service will use.
You can also specify these properties in the pom.xml file.

.pom File

Maven reads details about the build from the pom.xml file. You need to configure it to get the VirtServer Maven plugin from the repository and add a ReadyAPI test to the test phase of the build lifecycle.

You can find a sample Maven configuration below. If you already have your own configuration, copy the necessary elements to it.

Sample Maven functional test

Below is a sample pom.xml file that runs the Sample-SOAP-project.xml project. You can find this project in the <ReadyAPI installation directory>\tutorials folder. To use the sample:

  • Create a new pom.xml file and copy the sample code to it. Make sure to specify the same version as the ReadyAPI version you have.

  • Place the Sample-SOAP-project.xml project file in the folder where the pom.xml file is located.

  • Make sure VirtServer is running on localhost and uses port 8080.

  • Run the Maven build by using the command described above.

If you already have a pom.xml file, copy the elements to it to include your test in the build.

<project xmlns="" xmlns:xsi=""

   <!--Add the SmartBear ReadyAPI plugin repository.-->
   <!--Maven will download the plugin from the specified URL.-->

    <!--Specify the connection properties-->
    <!--Configure the profile-->
                        <!--The plugin groupID used to uniquely identify the project with the plugin.-->
                         <!--The plugin artifactId used to find the plugin in the project.-->
                        <!--Specifies your VirtServer version. Maven will use the appropriate plugin version.-->
                        <!-- IMPORTANT: Must be the same as your VirtServer version.-->
                            <!--The name of the virtual service in the project.-->
                            <virtName>ServiceSoapBinding MockService</virtName>
                            <!--The full path to the VirtServer instance.-->
                            <!--The number of the port the virtual service will use.-->
                            <!--If true, VirtServer will start the virtual service immediately. Otherwise, you will need to start the service later.-->
                            <!--If true, the existing virtual service with the same name will be replaced.-->
                            <!--Otherwise, the old vert will stay on VirtServer.-->
                            <!--Add an execution to deploy and start the virtual service before the integration test phase.-->
                            <!--Add an execution to stop and undeploy a virtual service after the integration test phase.-->
                    <!--Use the groovy-maven-plugin to check that the virtual service has been deployed successfully.-->
                                    <source>import org.apache.maven.plugin.MojoExecutionException
                                    String urlString = 'http://${}:${virt.port}/accountcreation'
                                    if (new URL(urlString).text.contains('Welcome!')) {
                                        println 'Successfully contacted deployed virtual service'
                                    } else {
                                        throw new MojoExecutionException("Couldn't contact deployed virtual service on $urlString")


See Also

Different Ways of Running VirtServer

Highlight search results