In order to collaboratively work on a SoapUI project which is checked into a git repository (or any other version control system) you must follow a few simple rules to make merging easier and to keep changes trackable.
This tutorial will show you how you can accomplish this with git and SourceTree on a Windows environment. But the process can also be applied to other environments.
- Install SoapUI
- Install git
- Install SourceTree
Enable Pretty Printing for the SoapUI Project files
In order to make merges as easy as possible you must enable pretty printing for your SoapUI project files – because otherwise SoapUI will create stupendiously long lines which can never be savely merged.
For example a SoapUI project file which does not use pretty printing looks like this:
It is impossible for any line based version control system to reasonably detect changes to a line which is 8000 characters long. So the idea is to make break long lines into seperate lines before checking in changes.
To enable pretty printing for SoapUI project files goto to your soapUI preferences and check the following options in the WSDL Settings section.
File > Preferences > WSDL Settings and check these options:
- Pretty Print
- Pretty Print Project Files
- Trim WSDL
Project file normalization
Besides enabling pretty printing you can further reduce the risk of running into merge conflicts by noramalizing the XML of the SoapUI project file before committing it.
The normalization process
In order to normalize a SoapUI project file (or any other XML file for that matter) you should perform the following steps for all lines of the file:
- Pretty print the XML (this is done by SoapUI itself)
- Remove leading and trailing spaces or tabs on each line
- Replace all session ids which have been added by SoapUI while running the test cases
- Remove empty lines
The normalization tool
Because all steps for normalizing a SoapUI project file mentioned above (except for the pretty printing) you need to utilize an external tool for this.
I have written a small tool called “soapui-project-normalization” for this which can be used on all platforms alike:
# !/bin/bash inputfile="./soapui-project.xml" tempfile="./temp.xml" # Normalize the project file ./soapui-project-normalization $inputfile > $tempfile cp $tempfile $inputfile rm $tempfile
set inputfile=".\soapui-project.xml" set tempfile=".\temp.xml" .\soapui-project-normalization.exe %inputfile% > %tempfile% copy %tempfile% %inputfile% del %tempfile%
The Development process (in SourceTree)
Pull changes from the remote master
Before you start working on a new feature you should always pull the lastest changes from your remote master.
Implement a new feature
A new feature should (ideally) be based on the latest version of the remote branch and should be developed in a separate feature branch.
The whole process has the following seven steps:
- Pull from your remote master (to make sure you are basing your changes on the latest version of the project)
- Create new branch for the new feature
- Add and test your changes
- Normalize the project file
- Commit your changes to your feature branch
- Switch back to master
- Pull changes from the remote master
- Merge the new feature branch into master
- Push change to remote master
To avoid conflict you should make sure that your coworkers are not making changes to the same sections of the project file than you.
… or switching between commits can be very helpful when for example you want to
- add a quick bug fix to the master branch
- base your new feature on a version you know is working correctly
- identify problems and bugs that have been introduced during the last commits