Running SOAP UI Tests in Teamcity using MSBuild
One of the web services we have has a bunch of SOAP UI Tests. I wanted to make sure when this was run on the build server we have good feedback for each test case rather than a whole build running a pack of tests and telling you if it failed or passed. Kind of a reason i was moving this build away to Teamcity from cruise control
The MSBuild script is as below. I had to define the variables I need and the Directory where all project files for Soap UI can be found.
1: <Import Project="$(MSBuildExtensionsPath)\MSBuildCommunityTasks\MSBuild.Community.Tasks.Targets" />
4: <SoapTestTool>C:\Program Files\eviware\soapUI-4.0.0\bin\testrunner.bat</SoapTestTool>
The next thing I had to do was run each project file using the SOAP Ui testrunner.bat file.
The options I have used –j will ensure JUnit style reports are pushed out of the Soap UI test runner, for local builds you could just make it push out Html reports
-h allows you to specify the host header to use for your Urls, The host header you supply here will override what is stored in the SOAP UI projects , so you run these tests on different sites based on your environment.
I have done a FileUpdate because i wanted to change Urls of the service from the old server to the ones on the new servers, you wont need this and it can be ignored
2: <Target Name="ConfigureSoapUITests">
3: <MakeDir Directories="$(SoapUIDir)\Report"/>
5: <SoapUIProjectFiles Include="$(SoapUIDir)\*-soapui-project.xml"/>
7: <!-- Replace old server urls with new ones -->
8: <FileUpdate Files="@(SoapUIProjectFiles)" Regex="$(someurl)" ReplacementText="$(newurl)" IgnoreCase="true"/>
11: <Target Name="RunFunctionalSoapUITests" DependsOnTargets="ConfigureSoapUITests">
12: <!--Run all the soap ui functional tests-->
13: <Exec Command=""$(SoapTestTool)" "%(SoapUIProjectFiles.Identity)" -h "$(HostHeader)" -I -r -a -j -f "$(SoapUIDir)\Report"" />
At this point I hooked up the MSBuild target to run on Teamcity using the MSBuild runner, for the target “RunFunctionalSoapUITests”. The feedback wasn’t good
The final bit you need to do is configure Teamcity to read the xml styled junit reports that the test runner is spitting out. You can do this using the Build feature option for XmlReport processing as shown in the screen shot.
Now trigger the build if you have sorted out all the other variables required you can run the build and see the output on Teamcity, pretty good really on test case by test case basis.
For failed tests I added a configuration for artifacts as follows, Teamcity will show you the response but to see the entire request response file , you need to setup artifacts as follows. All failed test cases create a .txt file which ends with FAILED.txt, so I push these as artifacts and i can see this for failed tests,
SoapUI/Report/*FAILED.txt => FailedTests
I find this useful that with little effort so much could be done and feedback is really good