Home > Deployment > MsBuild execution of SoapUI testrunner

MsBuild execution of SoapUI testrunner

January 20th, 2010 Leave a comment Go to comments

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">

    <SoapUiProject Condition="'$(TestProject)'==''">agent-soapui-project.xml</SoapUiProject>
    <SoapUITestResultsFolder Condition="'$(SoapUITestResultsFolder)'==''">$(MSBuildProjectDirectory)</SoapUITestResultsFolder>

    <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)'!=''"/>

    <JAVA_HOME Condition="'$(JAVA_HOME)'==''">$(SoapUiPath)\..\jre</JAVA_HOME>
    <SoapUiRunner>&quot;$(SoapUiPath)\testrunner.bat&quot; $(TestProject) @(Args,' ')</SoapUiRunner>

  <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 Name="AcceptanceTests" DependsOnTargets="CheckDependencies">
    <Message Text="Building Test Command: $(SoapUiRunner)"/>
    <Exec Command="$(SoapUiRunner)"/>

  <Target Name="HelpTest">
    <Message Text="
    msbuild /t:TestAll
    Variables that can be overridden:

     - TestAll
     - AcceptanceTests
    - soapUI must be installed to $(SoapUiPath)
    - JAVA_HOME - currently set to: $(JAVA_HOME)
             " />



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

Categories: Deployment Tags: , ,
  1. March 9th, 2010 at 00:41 | #1

    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

  2. todd
    March 10th, 2010 at 18:24 | #2


    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.


  3. sv
    February 15th, 2011 at 17:57 | #3

    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

  4. todd
    February 15th, 2011 at 18:12 | #4

    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.


  5. sv
    March 9th, 2011 at 04:12 | #5

    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


    "$(SoapUiPath)\testrunner.bat" @(Args,’ ‘)-r -o -g "$(TestProject)"

  1. No trackbacks yet.