Tuesday, July 10, 2012

Bamboo and SOAPUI integration

Install SOAPUI 4.5:

zip soapUI-x32-4_5_0.sh into soapUI-x32-4_5_0.zip (transferring .sh file got corrupted, need to set binary mode)

unzip soapUI-x32-4_5_0.zip on target /home/soa

chmod 755 soapUI-x32-4_5_0.sh

run in non-graphic mode, install to /home/soa/SmartBear/soapUI-4.5.0/

the installer will install also a Java 7 JRE into /home/soa/SmartBear/soapUI-4.5.0/jre, rename this directory to /home/soa/SmartBear/soapUI-4.5.0/jreORI so that SOAPUI will use the default java installation ( with Java 7 I had problems with this error:
[SoapUITestCaseRunner] java.lang.UnsatisfiedLinkError: /home/soa/SmartBear/soapUI-4.5.0/jre/lib/i386/xawt/libmawt.so: libXrender.so.1: cannot open shared object file: No such file or directory)

cd /home/soa/SmartBear/soapUI-4.5.0/bin

copy here your SOAPUI shop.xml test

./testrunner.sh -s"Configuration Service TestSuite" -c"Get terminal configuration" -j "shop.xml"

the -j option will generate a TEST-Configuration_Service_TestSuite.xml file in JUnit format, with the result of the test. The file name comes from 'testSuite name="Configuration Service TestSuite"'

Create a Bamboo plan

choose a "Script" task
you must choose to run a script https://confluence.atlassian.com/display/BAMBOO/Script

Script body= ./testrunner.sh -s"Configuration Service TestSuite" -c"Get terminal configuration" -j "shop.xml"

Working Sub Directory= /home/soa/SmartBear/soapUI-4.5.0/bin

then we add a JUnit Parse task:
Specify custom results directory=/home/soa/SmartBear/soapUI-4.5.0/bin/TEST-*.xml

Enable the project in dashboard
Run it

It fails saying "Could not find test result reports in the /home/soa/bamboohome/xml-data/build-dir/SOAPUITEST-SOAPUITEST-JOB1 "

in fact the /home/soa/bamboohome/xml-data/build-dir/SOAPUITEST-SOAPUITEST-JOB1/ was created, but only build-number.txt is there.

SoapUITestCaseRunner must be told WHERE to write the blessed JUnit TEST-bla.xml result.

The SoapUITestCaseRunner code says:

SoapUIOptions options = new SoapUIOptions( "testrunner" );
options.addOption( "e", true, "Sets the endpoint" );
options.addOption( "s", true, "Sets the testsuite" );
options.addOption( "c", true, "Sets the testcase" );
options.addOption( "u", true, "Sets the username" );
options.addOption( "p", true, "Sets the password" );
options.addOption( "w", true, "Sets the WSS password type, either 'Text' or 'Digest'" );
options.addOption( "i", false, "Enables Swing UI for scripts" );
options.addOption( "d", true, "Sets the domain" );
options.addOption( "h", true, "Sets the host" );
options.addOption( "r", false, "Prints a small summary report" );
options.addOption( "M", false, "Creates a Test Run Log Report in XML format" );
options.addOption( "f", true, "Sets the output folder to export results to" );
options.addOption( "j", false, "Sets the output to include JUnit XML reports" );
options.addOption( "m", false, "Sets the maximum number of TestStep errors to save for each testcase" );
options.addOption( "a", false, "Turns on exporting of all results" );
options.addOption( "A", false, "Turns on exporting of all results using folders instead of long filenames" );
options.addOption( "t", true, "Sets the soapui-settings.xml file to use" );
options.addOption( "x", true, "Sets project password for decryption if project is encrypted" );
options.addOption( "v", true, "Sets password for soapui-settings.xml file" );
options.addOption( "D", true, "Sets system property with name=value" );
options.addOption( "G", true, "Sets global property with name=value" );
options.addOption( "P", true, "Sets or overrides project property with name=value" );
options.addOption( "I", false, "Do not stop if error occurs, ignore them" );
options.addOption( "S", false, "Saves the project after running the tests" );

so I do

/home/soa/SmartBear/soapUI-4.5.0/bin/testrunner.sh -s"Configuration Service TestSuite" -c"Get terminal configuration" -j "/home/soa/SmartBear/soapUI-4.5.0/bin/shop.xml" -f/home/soa/bamboohome/xml-data/build-dir/SOAPUITEST-SOAPUITEST-JOB1/

and the result is written in /home/soa/bamboohome/xml-data/build-dir/SOAPUITEST-SOAPUITEST-JOB1/

the second step is simply
parse junit
Specify custom results directory=**/TEST*.xml

where the meaning of -s and -c parameters are:

<con:entry key="TestSuite" value="Configuration Service TestSuite"/>
<con:entry key="TestCase" value="Get terminal configuration"/>

-s = suite
-c = case


Integrating also SVN checkout:

Put your SOAPUI project in SVN

For instance:

Create Bamboo Plan

Create SVN repository

Source Repository= Subversion

Display Name = pippo2_SoapUI

Repository URL = https://nessvn1.acme.com/svn/pippov2/PPP_AutomatedTests/SOAPUIArtifacts/

Username= avernetto Password=bla
Create SOAPUI checkout task

Repository = pippo2_SoapUI
Create Script task

Task Description=Testrunner

Script Location=Inline

Script body=/home/soa/SmartBear/soapUI-4.5.0/bin/testrunner.sh -s"Configuration Service TestSuite" -j "/home/soa/bamboohome/xml-data/build-dir/SOAPUITEST-SOAPUITEST-JOB1/shop-conf-soapui-project.xml" -f/home/soa/bamboohome/xml-data/build-dir/SOAPUITEST-SOAPUITEST-JOB1/
Create JUnit Parser task

Task description=parse junit

Specify custom results directories=*/TEST.xml
Run the plan

Examine the content of /home/soa/bamboohome/xml-data/build-dir/SOAPUITEST-SOAPUITEST-JOB1/ folder for all artifacts being generated

1 comment:

lazykate said...

Thanks this was really useful in setting up SoapUI with my Bamboo. I would NEVER have figured out needing the parser task!

I only had one difference - I couldn't use the custom directory for the script task. so I let it use my build folder and just path to the 'test-result' sub folder.

It's quite simple in the end (but still took hours to get right!)

Script Task:

/opt/SoapUI-5.1.3/bin/testrunner.sh -j -M -f test-reports tests/SOAPUI/My-API-soapui-project.xml

Junit Parse tasks

Custom Results: test-reports/TEST-*.xml