MsBuild execution of SoapUI testrunner
I have just been writing an msbuild runner to wrap testrunner for soapUI. Here it is. There are a couple of techniques to note:
- stacking the args for the commandline in an
ItemGroup(see thanks below) - don’t forget to Html Escape quots when invoking command line ie
&quot - I also dependency check for each
- And the usual that the default target is Help and it tells about the targets and dependencies
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="HelpTest" ToolsVersion="3.5" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<SoapUiProject Condition="'$(TestProject)'==''">agent-soapui-project.xml</SoapUiProject>
<SoapUITestResultsFolder Condition="'$(SoapUITestResultsFolder)'==''">$(MSBuildProjectDirectory)</SoapUITestResultsFolder>
</PropertyGroup>
<ItemGroup>
<Args Include="-a"/>
<Args Include="-e$(Endpoint)" Condition="'$(Endpoint)'!=''"/>
<Args Include="-s$(TestSuite)" Condition="'$(TestSuite)'!=''"/>
<Args Include="-c$(TestCase)" Condition="'$(TestCase)'!=''"/>
<Args Include="-f$(SoapUITestResultsFolder)" Condition="'$(SoapUITestResultsFolder)'!=''"/>
</ItemGroup>
<PropertyGroup>
<SoapUiPath>$(ProgramFiles)\eviware\soapUI-3.0.1\bin</SoapUiPath>
<JAVA_HOME Condition="'$(JAVA_HOME)'==''">$(SoapUiPath)\..\jre</JAVA_HOME>
<TestProject>$(MSBuildProjectDirectory)\src\AcceptanceTest\$(SoapUiProject)</TestProject>
<SoapUiRunner>"$(SoapUiPath)\testrunner.bat" $(TestProject) @(Args,' ')</SoapUiRunner>
</PropertyGroup>
<Target Name="TestAll" DependsOnTargets="AcceptanceTests"/>
<Target Name="CheckDependencies">
<Error Text="SoapUI testrunner is not installed at: $(SoapUiPath)" Condition="!(Exists('$(SoapUiPath)'))"/>
<Error Text="JAVA_HOME environment variable not set correctly to point to an JRE" Condition="!Exists('$(JAVA_HOME)')"/>
</Target>
<Target Name="AcceptanceTests" DependsOnTargets="CheckDependencies">
<Message Text="Building Test Command: $(SoapUiRunner)"/>
<Exec Command="$(SoapUiRunner)"/>
</Target>
<Target Name="HelpTest">
<Message Text="
msbuild /t:TestAll
Variables that can be overridden:
SoapUiProject=soapui-project.xml
SoapUITestResultsFolder=$(MSBuildProjectDirectory)
Endpoint=http://12.0.0.7:8090/SERVICE
TestSuite=WorkSuite
TestCase=UpdateCase
Targets:
- TestAll
- AcceptanceTests
Dependencies:
- soapUI must be installed to $(SoapUiPath)
- JAVA_HOME - currently set to: $(JAVA_HOME)
" />
</Target>
</Project>
Reference:
The technique for stacking args in the ItemGroup is fro:
- http://weblogs.asp.net/lorenh/archive/2008/12/11/msbuild-trick-for-making-lt-exec-gt-calls-more-maintainable.aspx
- http://weblogs.asp.net/lorenh/archive/2008/12/11/msbuild-trick-for-making-lt-exec-gt-calls-more-maintainable.aspx
Hello Todd,
saw this post and liked it a lot! Great work – you just releaved me from some really tedious work.
But…. have you seen a way to override some of the endpoints in the SOAPUi file?
I have to get a security token from an external service and want to keep the endpoint for that service “untouched” from the override I supply in the MSBuild target.
you can read more about my experience on this here: http://www.marcusoft.net/2010/03/soapui-and-testing-wcf-services-how-i.html
And here is the praise for this post, of course
http://www.marcusoft.net/2010/03/soapui-and-msbuild.html
Marcus,
Thanks for the nice comments. I did this work a month of two ago and I plain forget the details. But I thought that I there was a way to do what you want. I think that you can add “scripting” to a service. Alternatively, you create a mockService (in the soapUI) approach. Sorry I can’t help you anymore than that.
If you are doing this work, it could be worthwhile checking out fitLibraryWeb (http://sourceforge.net/apps/mediawiki/fitlibrary/index.php?title=Main_Page) for its web service testing. Centrally, it is the same approach as soapui.
todd
excellent post…. thank you so much for this post .. it worked like any thing.. Also if you don’t mind i have one more help needed, When I run this project file from ms build(TFS) soapUI test runs as expected but It is not displaying test results and code coverage results
can you please help me to generate test results and code coverage results with in the build
Default Configuration and Platform
Here is the results below
0 error(s), 0 warning(s)
1 projects/solutions compiled
No Test Results
No Code Coverage Results
Thanks again for your help
SR
To get code coverage on your CLR objects you need attach to the process. You should be able to google that.
However, I not sure that code coverage is the solution here. These are system tests and you’ll get high code coverage but won’t mean much. You should rather a layered strategy and get code coverage on unit and integration tests only. I have other blogs on layer tests.
–tb
Thanks you so much for all your help,
Finally I am able to save the soapUI results on output folder, now I am planing to send an email to every with results once build is completed either in HTML format or links
Here is the MSbuild file that I am using but some thing i am missing in the file, can you please help me to resolve this issue
NightlyBuildProject.xml
\\ABCD\build_output\SoapUI_Results
$(ProgramFiles)\eviware\soapUI-Pro-3.6.1\bin
$(MSBuildProjectDirectory)\$(SoapUiProject)
"$(SoapUiPath)\testrunner.bat" @(Args,’ ‘)-r -o -g "$(TestProject)"