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
{ 2 } Comments
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
Post a Comment