Blayter.com

Using MXUnit with Bamboo

I've setup MXUnit and Hudson before using the great instructions found at the MXUnit Blog. I've recently setup my tests to run through Bamboo from Atlassian. There were a couple of things that I learned in the process.

For the most part Bamboo is a lot like Hudson but there are some special things you can do to pass parameters from Bamboo into your ANT script. In the configuration of the job you can pass ANT parameters in the target field. So since I setup my ANT to copy the files from my Bamboo server to my development server for the running of the tests I wanted the root path of Bamboo to be dynamic. I ended up entering the following for my target field.
main -Dbamboo.workingDirectory=${bamboo.build.working.directory}
You can find a list of variables you can pass from Bamboo to ANT here.

Another lesson learned was that the application that I was dealing with was quite large and I opted not to do a clean build every time. So Bamboo would essentially just update its local copy of the site and the changes would be propagated to the development server. When I had first started my ANT script I had all the tests being executed via a single <directory> call. Some of the tests take upwards of 3 minutes each to execute so I changed the ANT script to use the <testcase> instead. This helped by breaking up all of the tests into separate HTTP calls and I was able to get better results in executing the tests. The bad part is that since I didn't have a clean checkout the xml file generated from the <directory> call was left in there. So I kept getting inaccurate results back to bamboo. My resolution for this was adding a couple of lines in my ANT file to clean out the testresults folder.
<property name="junit.out.dir.xml" value="testresults" />
<delete dir="${bamboo.workingDirectory}\${junit.out.dir.xml}\" failonerror="false"/>
<mkdir dir="${bamboo.workingDirectory}\${junit.out.dir.xml}"/>

Comments
Hi , Thanks for the great post ..

Can you please let me know how to pass the class path to the ant file .Right now i am getting this error


Jan-2014 06:08:57   /opt/Atlassian/agents/05/xml-data/build-dir/STRADA-STRADADEV-DEV/build-dev.xml:24: taskdef class org.mxunit.ant.MXUnitAntTask cannot be found
09-Jan-2014 06:08:57    using the classloader AntClassLoader[]
09-Jan-2014 06:08:57   
09-Jan-2014 06:08:57   Total time: 0 seconds
09-Jan-2014 06:22:35   Error occurred while running Task 'Move to DEV(2)' of type com.atlassian.bamboo.plugins.ant:task.builder.ant.
09-Jan-2014 06:22:35   com.atlassian.bamboo.task.TaskException: Failed to execute task
# Posted By Sumo | 1/9/14 9:01 AM