Tuesday 7 March 2017

Maven : Integration of tests

In the changing environment, the way tests are executed are also changing. Once we moved to agile mode from a traditional waterfall or v-Cycle mode of development we saw the need of automation. However, there is always a next step to be done, and in this case the obvious next step is to integrate them with development builds. There could be various ways to achive the same among which the most common one is deploying your tests on Jenkins. It provides a common platform where the development builds are done and at the same time the test builds can be done. In this article we will explore the possibility to integrate the various automated tests.

Maven : Integration of SoapUI automated Tests

SoapUI includes a Maven plugin for running SoapUI tests and mocks during Maven build. To use the correct version of SoapUI, you will have to see under the Soap Maven Repository. Maven should know about the soap repository and dependencies related to your project and it can be achieved by updating the maven settings which would be available at "conf" directory under maven binary location.
Edit the settings.xml and update the below elements as needed.
  • Local Repository : Location of the directory where dependency repository would be stored locally for compilation
  • Mirror : Location of maven mirror repository.
  • Repository : maven repositories and other repository where dependent tools and configuration can be found

  • PluginRepository : maven repositories and other repository where dependency plugins can be found
Attached an example settings.xml which is being used for one of the project.



Once the settings are configured your maven can execute soapUI tests.
The second step is to create pom files for the execution of the SoapUI tests. You may have two scenario here, one where you only have one project file and the other where you have multiple project files. For single project file based execution it is easier as you have to create only one pom file which can be located at the same place as the SoapUI project file. For multiple project file however, we need to organize our project to be in the way below :
  • Soap-Project
    • Project-1
      • Soap-Project-file.xml (Soap UI project file)
      • pom.xml (Child pom file configured for this project)
    • Project-2
      • Soap-Project-file.xml (Soap UI project file)
      • pom.xml (Child pom file configured for this project)
    • Project-n
      • Soap-Project-file.xml (Soap UI project file)
      • pom.xml (Child pom file configured for this project)
    • pom.xml (master pom file)
Prefer to use names of the files or directories without spaces or special characters to avoid referencing issues.

The master pom file would look as below :


A typical child pom file would look as below :


You can configure additional details for the project execution by further addition following parameters
  • projectFile : Specified the name of the SoapUI project file to use, default value is ${pom.artifactId}-soapui-project.xml
  • testSuite : Specifies the name of the TestSuite to run
  • testCase : Specifies the name of the TestCase to run
  • endpoint : Overrides the service endpoint to be invoked by any TestRequests
  • host : Overrides the target host:port to be invoked by any TestRequests
  • username : Overrides the username used by any TestRequests run
  • password : Overrides the password used by any TestRequests run
  • domain : Overrides the domain used by any TestRequests run
  • printReport : Controls if a small test report should be printed to the console (true/false)
  • outputFolder : Set which folder results/reports are saved to
  • junitReport : Turns on creation of JUnit-reports, (true/false)
  • exportAll : Controls if all test requests should be exported (default only exports errors), (true/false)
  • settingsFile : Specifies SoapUI settings file to use
  • wssPasswordType : Specifies WSS password type
  • project.password : Specifies password for encrypted project
  • settingsFile.password : Specifies password for encrypted settings file
  • globalProperties : Sets global properties
  • projectProperties : Sets project properties
  • saveAfterRun : Saves project file after run
  • testFailIgnore : Ignore failed tests.
  • reportFormat : Sets formats for created report. Pro only.
  • reportName : Sets which report to create. Pro only.
  • coverage : Sets the output to include Coverage HTML reports. Pro only.
  • environment : Sets the active environment. Pro only.
You will have to replicate the above configuration for all the child projects. Child project names in the pom, the directory name and the name mentioned under the master pom file should be same. Once the pom configuration is done you can test your execution with below command.
 > mvn -U clean install
In case of integration of mock service you will have to do some minor modification in the phase and goal of the execution section. The execution should appear as below :




 You can also define the following properties in order to customize your mock service on run time
  • projectFile : Specified the name of the SoapUI project file to use, default value is ${pom.artifactId}-soapui-project.xml
  • mockService : Specified the MockService to run
  • port : The local port to listen on, overrides the port configured for the MockService
  • path : The local path to listen on, overrides the path configured for the MockService
  • noBlock : Turns off blocking when MockRunner has started
  • settingsFile : Specifies SoapUI settings file to use, will contain path to integrated tool to run
  • project.password : Specifies password for encrypted project file
  • settingsFile.password : Specifies password for encrypted soapui settings file
  • saveAfterRun : Saves project file after run.
For more details following links can be referenced

No comments:

Post a Comment