Archive

Posts Tagged ‘soapui’

MsBuild execution of SoapUI testrunner

January 20th, 2010 5 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">

  <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>&quot;$(SoapUiPath)\testrunner.bat&quot; $(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

Categories: Deployment Tags: , ,