Ant script to execute Soap UI Mock and Soap UI Test suite - soap

I want to integrate soup ui project to jenkins. I have a test suite and a mock service , The mock service should be running in order to test the test suite.
I wrote a build script to execute the mock service first and then the test case. The following is the script
<project name="test" default="DIAG_COMPLETE" basedir=".">
<property name="project" value="./Complete--soapui-project.xml" />
<target name="DIAG_COMPLETE" depends="DIAG" >
<exec executable="D:\Soapui\soapUI-4.5.2\bin\testrunner.bat" failonerror="false" failifexecutionfails="false" >
<arg line="-sdiag_upload_tc -rja -f./reports ${project}"/>
</exec>
</target>
<!-- invokes the mock service -->
<target name="DIAG" >
<exec executable="D:\Soapui\soapUI-4.5.2\bin\mockservicerunner.bat" failonerror="false" failifexecutionfails="false" >
<arg line="-m'DBDiagnosticDataTransmissionSOAPBinding MockService' -p8088 -a/mockDBDiagnosticDataTransmissionSOAPBinding -b ${project}"/>
</exec>
</target>
</project>
I am not sure if this is the write approach.
Only if this works fine, I can integrate it with jenkins.
and this does not work because the mock service is not getting started.
I want an approach to proceed further in my jenkins integration.
Thanks Jacob Marshell

Related

Phing phpunit "plugin with stackIndex "1" already registered" error

For my Zend Framework (v1.12) project deployment Im using Phing. It deploys front-end and back-end applications. Everything goes fine, untill Phing starts phpunit testing:
<!-- Testing backend -->
<target name="backend-test" description="Testing backend system">
<phpunit codecoverage="false" haltonerror="true" haltonfailure="true" printsummary="true" bootstrap="${path.build}/${DSTAMP}${TSTAMP}/admin/tests/bootstrap.php">
<batchtest>
<fileset dir="${path.build}/${DSTAMP}${TSTAMP}/admin/tests">
<include name="**/*Test.php" />
</fileset>
</batchtest>
<formatter type="summary" usefile="false" />
</phpunit>
</target>
<!-- Testing frontend environment -->
<target name="site-test" description="Testing frontend system">
<phpunit codecoverage="false" haltonerror="true" haltonfailure="true" printsummary="true" bootstrap="${path.build}/${DSTAMP}${TSTAMP}/site/tests/bootstrap.php">
<batchtest>
<fileset dir="${path.build}/${DSTAMP}${TSTAMP}/site/tests">
<include name="**/*Test.php" />
</fileset>
</batchtest>
<formatter type="summary" usefile="false" />
</phpunit>
</target>
Back-end part phpunit tests succeed, but when it starts testing front-end - it fails it error:
[phingcall] Plugin with stackIndex "1" already registered
[phingcall] #0 /var/www/zend/Controller/Front.php(733): Zend_Controller_Plugin_Broker->registerPlugin(Object(Application_Plugin_ACL), 1)
[phingcall] #1 /var/www/_qa/build/201311181711/admin/application/Bootstrap.php(199): Zend_Controller_Front->registerPlugin(Object(Application_Plugin_ACL), 1).......
Any ideas? Your help would be appreciated.
Your bootstrap is being called twice (or at least the resource [_init function]).
You get this error because you can't define an other plugin instance for the same stack index.
You should try to find a way to mock all periferral classes loaded in your bootstrap and test each of these classes individually.
An other way would be to bootstrap your application in the phpUnit setup method and make sure it's destroyed in the teardown. This will be more ressource instensive and will most likely slow down your tests as the whole Zend stack will be instanciated, then killed, then re-instantiated for each of your test cases.

Ant script stops executing targets after the target build-war-deploy of a gwt project

I have an ant script which does in the beginning some checks and then compiles the code and deploys it to the tomcat server. The script for the build-war-deploy process looks like this:
<target name="build-war-deploy" depends="clean-up,gwtc,check-settings" description="Package GWT app to web archive and deploy to web server">
<war basedir="${war.dir}" destfile="${deploy.dir}/${app.name}.war" webxml="${webinf.dir}/web.xml">
<!-- <include name="WEB-INF/**" /> -->
<webinf dir="${webinf.dir}/">
<include name="**/*.jar" />
</webinf>
</war>
</target>
This target works perfectly fine, meaning after running the ant script the application is indeed deployed on tomcat.
After the build-war-deploy target I need to do some cleanup processes and therefore I created some other targets and added an dependency to the build-war-deploy target so that it is being executed afterwards.
<target name="cleanup" depends="build-war-deploy" description="clean up processes">
<exec dir="./" executable="python" failonerror="true">
<arg line="deploy_cleanup.py ${app.name}" />
</exec>
</target>
However, after the ant script executes the build-war-deploy target it stops and says that the build was successful. Does anyone know why it did not perform the last target?
build-war-deploy:
[war] Building war: C:\Apache Tomcat\apache-tomcat-6.0.33\webapps\test.war
BUILD SUCCESSFUL
Total time: 2 minutes 22 seconds
I would try using an outputproperty. Perhaps the python file is executing -- not doing what you want but executing and returning the results which you never see. I mean if the python script returns an error message, doesn't ant view that as successfully executing?
Something like:
<exec dir="./" executable="python" outputproperty="outProp" failonerror="true">
<arg line="deploy_cleanup.py ${app.name}" />
</exec>
<echo>${outProp}</echo>
outputproperty: The name of a property in which the output of the command should be stored. Unless the error stream is redirected to a separate file or stream, this property will include the error output.

PartCover generates empty output file

I'm currently trying to create a Nant task for our TeamCity setup so that our UnitTests are ran through Gallio and covered by PartCover. The task looks like this:
<!-- UnitTest Configuration -->
<!-- ====================== -->
<!-- This configuration runs the tests through Gallio with MbUnit together with
PartCover to get the results of the test together with the coverage results
-->
<target name="unitTest">
<echo message="Unittesting ${AssemblyToTest}"/>
<exec program="${Paths.Tools}\PartCover\Partcover.exe" failonerror="true">
<arg line="--target "${Paths.Tools}\Gallio\Gallio.Echo.exe"" />
<arg line="--target-work-dir ${AssemblyToTestLocation}"/>
<arg line="--target-args /r:Local "${AssemblyToTest}"" />
<arg line="--include "[${Tests.TestedAssemblyName}]*"" />
<arg line="--output ${Paths.Output}\Coverage.xml" />
</exec>
</target>
The tests are running, we can see this in TeamCity, and a Coverage.xml file is generated, but empty. There's only a single line in it.
Output of the variables:-
${Paths.Tools} : C:\Robinson\Trunk\
${Tests.TestedAssemblyName} : Name of the DLL
${AssemblyToTestLocation} : Path to the DLL
Am I missing something?
EDIT
The TeamCity application is running on a Windows Server 2003 R2 Server, and all the build-agents performing the work are currently running on Windows XP Systems, all 32bit installations.
I believe we covered this issue in https://github.com/sawilde/partcover.net4/issues/46
and the solution was along the lines of
--include [${Tests.TestedAssemblyName}*]* ?

How to rebuild solution using NAnt?

I am using following command in NAnt build file
<msbuild project="${appsdest}\${targetname}\${targetname}.sln"/>
appsdest and targetname are variable contain application project path and targetname is the variable contain project name to be rebuild.
but when using this command it build the solution but the time stamp of dlls are not updated.
I need to rebuild the solution and the latest dlls need to be place in debug folder.
can anyone tell me how to rebuild the solution using the msbuild command as written above?
Thanks
I don't use the MSBUILD tasks in NAnt, I just call the msbuild executable directly and it has worked well for me.
<target name="build">
<exec program="${MSBuildPath}">
<arg line='"${SolutionFile}"' />
<arg line="/property:Configuration=${SolutionConfiguration}" />
<arg value="/target:Rebuild" />
<arg value="/verbosity:normal" />
<arg value="/nologo" />
<arg line='/logger:"C:\Program Files\CruiseControl.NET\server\ThoughtWorks.CruiseControl.MsBuild.dll"'/>
</exec>
</target>
I write more about it here: http://enterpriseyness.com/2009/12/continuous-integration-with-cruise-control-net-nant
You need to use the 'Rebuild' target:
<msbuild project="${appsdest}\${targetname}\${targetname}.sln" target="Rebuild"/>

MSBuild. Check if windows service is installed

I'm new to msbuild and currently I'm trying to create msbuild script that will deploy my C# windows service to remote test server.
I'm thinking about using sc.exe utility for this purpose. Reading about it I didn't find a way to check whether windows service is installed on a remote server. If the service is installed then I need to stop it and update necessary files, otherwise I need to register the service.
P.S. For release builds I plan to use WiX to create MSI package.
You need MSBuild Comminity Tasks.
In latest build exists an example in MSBuild.Community.Tasks.v1.2.0.306\Source\Services.proj.
It will solve first part of your question:
<PropertyGroup>
<MSBuildCommunityTasksPath>$(MSBuildProjectDirectory)\MSBuild.Community.Tasks\bin\Debug</MSBuildCommunityTasksPath>
</PropertyGroup>
<Import Project="$(MSBuildProjectDirectory)\MSBuild.Community.Tasks\MSBuild.Community.Tasks.Targets"/>
<Target Name="Test">
<CallTarget Targets="DoesServiceExist" />
<CallTarget Targets="GetServiceStatus" />
<CallTarget Targets="ServiceControllerStuff" />
</Target>
<Target Name="DoesServiceExist">
<ServiceQuery ServiceName="MSSQLServer123" MachineName="127.0.0.1" >
<Output TaskParameter="Exists" PropertyName="Exists" />
<Output TaskParameter="Status" PropertyName="ServiceStatus" />
</ServiceQuery>
<Message Text="MSSQLServer Service Exists: $(Exists) - Status: $(ServiceStatus)"/>
</Target>
<Target Name="GetServiceStatus">
<ServiceQuery ServiceName="MSSQLServer" MachineName="127.0.0.1">
<Output TaskParameter="Status" PropertyName="ResultStatus" />
</ServiceQuery>
<Message Text="MSSQLServer Service Status: $(ResultStatus)"/>
</Target>
<Target Name="ServiceControllerStuff">
<ServiceController ServiceName="aspnet_state" MachineName="127.0.0.1" Action="Start" />
<ServiceController ServiceName="aspnet_state" MachineName="127.0.0.1" Action="Stop" />
</Target>
Those MSBuild task is just a wrapper around .Net class ServiceController. Take a look for documentation to understand how it works and how you can configure it in details.
Second part includes installing service. For that purpose sc.exe suits very well.
A complete solution is posted here. May help future visitors.
Update: Link updated as the other blogging service went down.