<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>a little madness &#187; Agile</title>
	<atom:link href="http://www.alittlemadness.com/category/agile/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.alittlemadness.com</link>
	<description>A man needs a little madness, or else he never dares cut the rope and be free. -Nikos Kazantzakis</description>
	<lastBuildDate>Wed, 11 Aug 2010 04:58:55 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Pulse Continuous Integration Server 2.2!</title>
		<link>http://www.alittlemadness.com/2010/08/11/pulse-continuous-integration-server-2-2/</link>
		<comments>http://www.alittlemadness.com/2010/08/11/pulse-continuous-integration-server-2-2/#comments</comments>
		<pubDate>Wed, 11 Aug 2010 04:58:55 +0000</pubDate>
		<dc:creator>Jason</dc:creator>
				<category><![CDATA[Agile]]></category>
		<category><![CDATA[Build]]></category>
		<category><![CDATA[Continuous Integration]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Zutubi]]></category>

		<guid isPermaLink="false">http://www.alittlemadness.com/?p=722</guid>
		<description><![CDATA[Big news today: Pulse 2.2 has graduated to stable!  This release includes a stack of new features and improvements, including:

Build UI overhaul: all tabs improved and restyled.
New logs tab: making it easier to access stage logs.
Featured artifacts: choose which artifacts should appear prominently.
Build navigator: easily move forward and backward through history.
Working copy browser: view [...]]]></description>
			<content:encoded><![CDATA[<p>Big news today: <a href="http://zutubi.com/products/pulse/">Pulse 2.2</a> has graduated to stable!  This release includes a stack of new features and improvements, including:</p>
<ul>
<li>Build UI overhaul: all tabs improved and restyled.</li>
<li>New logs tab: making it easier to access stage logs.</li>
<li>Featured artifacts: choose which artifacts should appear prominently.</li>
<li>Build navigator: easily move forward and backward through history.</li>
<li>Working copy browser: view working copies for in progress builds.</li>
<li>Move refactoring: move projects and agents in the template hierarchy.</li>
<li>Template navigation: navigate directly up and down a hierarchy.</li>
<li>Subscription by label: subscribe to notifications by project groups.</li>
<li>Agent executing stages: see what all agents are building at a glance.</li>
<li>Subversion exports: for faster and smaller builds.</li>
<li>Performance improvements: key for larger installations.</li>
</ul>
<p>See the <a href="http://zutubi.com/products/pulse/new/">new in 2.2 page</a> for full details.</p>
<p>In conjunction with this release, we&#8217;ve also given our <a href="http://zutubi.com/">website</a> a complete overhaul.  The new site has a fresher look, and communicates the key features of Pulse more directly.  The updates also include some new features: </p>
<ul>
<li>RSS feeds for news items.</li>
<li>Links to our latest blog posts on the front page.</li>
<li>An improved buying process, allowing multiple licenses to be purchased in one transaction.</li>
<li>Self-service renewal payments &#8211; just enter your current license key and go!</li>
<li>A more user-friendly downloads page.</li>
</ul>
<p>We hope you enjoy the new release, and the new site.  And please, <a href="mailto:support@zutubi.com">let us know</a> what you think!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.alittlemadness.com/2010/08/11/pulse-continuous-integration-server-2-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Simpler Ant Builds With the Ant Script Library</title>
		<link>http://www.alittlemadness.com/2010/07/29/simpler-ant-builds-with-the-ant-script-library/</link>
		<comments>http://www.alittlemadness.com/2010/07/29/simpler-ant-builds-with-the-ant-script-library/#comments</comments>
		<pubDate>Thu, 29 Jul 2010 09:39:21 +0000</pubDate>
		<dc:creator>Jason</dc:creator>
				<category><![CDATA[Agile]]></category>
		<category><![CDATA[Build]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Project Automation]]></category>
		<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://www.alittlemadness.com/?p=694</guid>
		<description><![CDATA[Introduction
Ant may be unfashionable these days, but it still has its advantages.  Key among these are familiarity and simplicity: most Java developers have worked with Ant, and with an Ant build what you get is what you see.  A major disadvantage, though, is that Ant provides very little out-of-the-box.  When you start [...]]]></description>
			<content:encoded><![CDATA[<h3>Introduction</h3>
<p><a href="http://ant.apache.org/">Ant</a> may be unfashionable these days, but it still has its advantages.  Key among these are familiarity and simplicity: most Java developers have worked with Ant, and with an Ant build what you get is what you see.  A major disadvantage, though, is that Ant provides very little out-of-the-box.  When you start a new project, you&#8217;ve got a lot of grunt work to endure just to get your code compiled, packaged, and tested.  An all-too-common solution, in the grand tradition of <a href="http://www.gnu.org/software/make/">make</a>, is to copy a build file from an existing project as an easy starting point.</p>
<p>Over the years, though, Ant has gradually expanded support for creating reusable build file snippets.  On top of this a few projects have emerged which aim to simplify and standardise your Ant builds, including:</p>
<ul>
<li><a href="http://www.easyant.org/">EasyAnt</a></li>
<li><a href="http://code.google.com/p/ant-master-build-scripts/">Ant Master Build Scripts</a></li>
<li><a href="http://www.exubero.com/asl/">Ant Script Library</a></li>
</ul>
<p>Today I&#8217;ve taken my first proper look at the latter, and so far I like what I see.</p>
<h3>The Ant Script Library</h3>
<p>In the author Joe Schmetzer&#8217;s own words:</p>
<blockquote><p>The Ant Script Library (ASL) is a collection of re-usable Ant scripts that can be imported into your own projects. The ASL provides a number of pre-defined targets that simplify setting up build scripts for a new project, bringing re-use and consistency to your own Ant scripts.</p></blockquote>
<p>ASL consists of several Ant XML files, each of which provides a group of related functionality via predefined targets.  For example, the <b>asl-java-build.xml</b> file defines targets for compiling and packaging Java code.  The <b>asl-java-test.xml</b> file extends this with the ability to run JUnit tests, and so on.  Essentially, ASL packages up all the grunt work, allowing you to concentrate on the small tweaks and extra targets unique to your project.  The modular structure of ASL, combined with the fact that it is just Ant properties and targets, makes it easy to take what you like and leave the rest.</p>
<h3>An Example</h3>
<p>Allow me to illustrate with a simple project I have been playing with.  This project has a straightforward directory structure:</p>
<ul>
<li>&lt;project root&gt;
<ul style="font-size: 1em;">
<li>asl/ &#8211; the Ant Script Library</li>
<li>build.xml &#8211; Ant build file</li>
<li>lib/ &#8211; Jar file depedencies</li>
<li>src/ &#8211; Java source files</li>
<li>test/ &#8211; JUnit-based test source files</li>
</ul>
</li>
</ul>
<p>To add ASL to my project, I simply downloaded it from the project <a href="http://www.exubero.com/asl/download.html">download page</a> and unpacked it in the <b>asl/</b> subdirectory of my project<sup>1</sup>.  Then I can start with a very simple build file that supports building my code and running the tests:</p>
<pre class="brush: xml;">&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;project name=&quot;zutubi-android-ant&quot; default=&quot;dist&quot;&gt;
    &lt;property name=&quot;java-build.src-dir&quot; location=&quot;src&quot;/&gt;
    &lt;property name=&quot;java-test.src-dir&quot; location=&quot;test&quot;/&gt;
    &lt;property name=&quot;java-build.lib-dir&quot; location=&quot;libs&quot;/&gt;

    &lt;property name=&quot;asl.dir&quot; value=&quot;asl&quot;/&gt;

    &lt;import file=&quot;${asl.dir}/asl-java-build.xml&quot;/&gt;
    &lt;import file=&quot;${asl.dir}/asl-java-test.xml&quot;/&gt;
&lt;/project&gt;</pre>
<p>Notice that I am using non-standard source locations, but that is easily tweaked using properties which are <a href="http://www.exubero.com/asl/reference.html">fully documented</a>.  With this tiny build file, let&#8217;s see what targets ASL provides for me:</p>
<pre class="brush: plain;">$ ant -p
Buildfile: build.xml

Main targets:

 clean                 Deletes files generated by the build
 compile               Compiles the java source
 copy-resources        Copies resources in preparation to be packaged in jar
 dist                  Create a distributable for this java project
 generate              Generates source code
 jar                   Create a jar for this java project
 test-all              Runs all tests
 test-integration      Runs integration tests
 test-run-integration  Runs the integration tests
 test-run-unit         Runs the unit tests
 test-unit             Runs unit tests
Default target: dist</pre>
<p>It&#8217;s delightfully simple!</p>
<h3>Adding Reports</h3>
<p>It gets better: ASL also provides reporting with tools like <a href="http://cobertura.sourceforge.net/">Cobertura</a> for coverage, <a href="http://findbugs.sourceforge.net/">FindBugs</a> for static analysis and so on via its <b>asl-java-report.xml</b> module.  The full range of supported reports can be seen in the <b>report-all</b> target:</p>
<pre class="brush: xml;">&lt;target name=&quot;report-all&quot;
        depends=&quot;report-javadoc, report-tests, report-cobertura, report-jdepend, report-pmd, report-cpd, report-checkstyle, report-findbugs&quot;
        description=&quot;Runs all reports&quot;/&gt;</pre>
<p>Having support for several tools out-of-the-box is great.  For my project, however, I&#8217;d like to keep my dependencies down and I don&#8217;t feel that I need all of the reporting.  Although the choice of reports is not something that is parameterised by a property, it is still trivial to override by providing your own report-all target.  This shows the advantage of everything being plain Ant targets:</p>
<pre class="brush: xml;">&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;project name=&quot;zutubi-android-ant&quot; default=&quot;dist&quot;&gt;
    &lt;property name=&quot;java-build.src-dir&quot; location=&quot;src&quot;/&gt;
    &lt;property name=&quot;java-test.src-dir&quot; location=&quot;test&quot;/&gt;
    &lt;property name=&quot;java-build.lib-dir&quot; location=&quot;libs&quot;/&gt;

    &lt;property name=&quot;asl.dir&quot; value=&quot;asl&quot;/&gt;

    &lt;import file=&quot;${asl.dir}/asl-java-build.xml&quot;/&gt;
    &lt;import file=&quot;${asl.dir}/asl-java-test.xml&quot;/&gt;
    &lt;import file=&quot;${asl.dir}/asl-java-report.xml&quot;/&gt;

    &lt;target name=&quot;report-all&quot;
            depends=&quot;report-javadoc, report-tests, report-cobertura, report-pmd, report-checkstyle&quot;
            description=&quot;Runs all reports&quot;/&gt;
&lt;/project&gt;</pre>
<p>Here I&#8217;ve included the <b>java-report</b> module, but defined my own <b>report-all</b> target that depends on just the reports I want.  This keeps things simple, and allows me to trim out a bunch of ASL dependencies I don&#8217;t need.</p>
<h3>Conclusion</h3>
<p>I&#8217;ve known of ASL and such projects for a while, but this is the first time I&#8217;ve actually given one a go.  Getting started was pleasantly simple, as was applying the small tweaks I needed.  So next time you&#8217;re tempted to copy an Ant build file, give ASL a shot: you won&#8217;t regret it!</p>
<p><br/></p>
<p>&#8211;<br />
<sup>1</sup> In this case I downloaded the full tarball including dependencies, which seemed on the large side (21MB!) but in fact can be easily trimmed by removing the pieces you don&#8217;t need.  Alternatively, you can start with the basic ASL install (sans dependencies) and it can pull down libraries for you.  Sweet <img src='http://www.alittlemadness.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .</p>
]]></content:encoded>
			<wfw:commentRss>http://www.alittlemadness.com/2010/07/29/simpler-ant-builds-with-the-ant-script-library/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Android Testing: XML Reports for Continuous Integration</title>
		<link>http://www.alittlemadness.com/2010/07/14/android-testing-xml-reports-for-continuous-integration/</link>
		<comments>http://www.alittlemadness.com/2010/07/14/android-testing-xml-reports-for-continuous-integration/#comments</comments>
		<pubDate>Wed, 14 Jul 2010 07:57:28 +0000</pubDate>
		<dc:creator>Jason</dc:creator>
				<category><![CDATA[Agile]]></category>
		<category><![CDATA[Android]]></category>
		<category><![CDATA[Build]]></category>
		<category><![CDATA[Continuous Integration]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Testing]]></category>

		<guid isPermaLink="false">http://www.alittlemadness.com/?p=680</guid>
		<description><![CDATA[Summary
This post introduces the Android JUnit Report Test Runner, a custom instrumentation test runner for Android that produces XML test reports.  Using this runner you can integrate your Android test results with tools that understand the Ant JUnit task XML format, e.g. the Pulse Continuous Integration Server.
The motivation and details of the runner are [...]]]></description>
			<content:encoded><![CDATA[<h3>Summary</h3>
<p>This post introduces the <a href="http://github.com/jsankey/android-junit-report">Android JUnit Report Test Runner</a>, a custom instrumentation test runner for Android that produces XML test reports.  Using this runner you can integrate your Android test results with tools that understand the Ant JUnit task XML format, e.g. the <a href="http://zutubi.com/products/pulse/">Pulse</a> Continuous Integration Server.</p>
<p>The motivation and details of the runner are discussed below.  For the impatient: simply head on over to the project <a href="http://github.com/jsankey/android-junit-report">home page</a> on GitHub and check out the README.</p>
<h3>Introduction</h3>
<p>If you&#8217;ve been following my <a href="/2010/06/29/android-functional-testing-vs-dependency-injection/">recent</a> <a href="/2010/07/06/android-testing-using-pure-unit-tests/">posts</a> you&#8217;ll know that I&#8217;ve been figuring out the practical aspects of testing Android applications.  And if you&#8217;ve been following for longer, you might know that my day job is development of the <a href="http://zutubi.com/products/pulse/">Pulse</a> Continuous Integration Server.  So it should come as no surprise that in my latest foray into the world of Android testing I sought to bring the two together <img src='http://www.alittlemadness.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .</p>
<h3>Status Quo</h3>
<p>Out of the box, the Android SDK supports running functional tests on a device or emulator via <a href="http://developer.android.com/guide/topics/testing/testing_android.html">instrumentation</a>.  Running within Eclipse, you get nice integrated feedback.  Unfortunately, though, there are no real options for integrating with other tools such as continuous integration servers.  Test output from the standard Ant builds is designed for human consumption, and lacks the level of detail I&#8217;d like to see in my build reports.</p>
<h3>The Solution</h3>
<p>On the upside, having access to the Android source makes it possible to examine how the current instrumentation works, and therefore how it can be customised.  I found that the default <a href="http://developer.android.com/reference/android/test/InstrumentationTestRunner.html">InstrumentationTestRunner</a> may be fairly easily extended to hook in extra test listeners.  So I&#8217;ve implemented a custom JUnitReportTestRunner that does just that, with a listener that generates a test report in XML format.  The format is designed to be largely compatible with the output of the Ant <a href="http://ant.apache.org/manual/Tasks/junit.html">JUnit task&#8217;s</a> XML formatter &#8212; the most widely supported format in the Java world.  Tools like Pulse can read in this format to give rich test reporting.</p>
<h3>How It Works</h3>
<p>As mentioned, the JUnitReportTestRunner extends the default InstrumentationTestRunner, so it can act as a drop-in replacement.  The custom runner acts identically to the default, with the added side-effect of producing an XML report.</p>
<p>For consistency with the SDK&#8217;s support for generating coverage reports, the XML report is generated in the file storage area of the <em>target application</em>.  The default report location is something like:</p>
<pre class="brush: plain;">/data/data/&lt;tested application package&gt;/files/junit-report.xml</pre>
<p>on the device.  To retrieve the report, you can use <b>adb pull</b>, typically as part of your scripted build.</p>
<h3>Using the Runner</h3>
<p>Full details on using the runner are provided in the README on the project <a href="http://github.com/jsankey/android-junit-report">home page</a>.  Briefly:</p>
<ul>
<li>Add the android-junit-report-&lt;version&gt;.jar to the libraries for your test application.</li>
<li>Replace all occurrences of <b>android.test.InstrumentationTestRunner</b> with <b>com.zutubi.android.junitreport.JUnitReportTestRunner</b>:
<ul style="font-size: 1em;">
<li>In the <b>android:name</b> attribute of the <b>instrumentation</b> tag in you test application&#8217;s <b>AndroidManifest.xml</b>.</li>
<li>In the <b>test.runner</b> property in the Ant build for your test application (<em>before</em> calling the Android <b>setup</b> task).</li>
<li>In the <b>Instrumentation runner</b> field of all Android JUnit Run Configurations in your Eclipse project.</li>
</ul>
</li>
<li>Add logic to your Ant build to run <b>adb pull</b> to retrieve the report after the tests are run.</li>
</ul>
<p>As an example for retrieving the report in your Ant build:</p>
<pre class="brush: xml;">&lt;target name=&quot;fetch-test-report&quot;&gt;
    &lt;echo&gt;Downloading XML test report...&lt;/echo&gt;
    &lt;mkdir dir=&quot;${reports.dir}&quot;/&gt;
    &lt;exec executable=&quot;${adb}&quot; failonerror=&quot;true&quot;&gt;
        &lt;arg line=&quot;${adb.device.arg}&quot;/&gt;
        &lt;arg value=&quot;pull&quot; /&gt;
        &lt;arg value=&quot;/data/data/${tested.manifest.package}/files/junit-report.xml&quot; /&gt;
        &lt;arg value=&quot;${reports.dir}/junit-report.xml&quot; /&gt;
    &lt;/exec&gt;
&lt;/target&gt;</pre>
<h3>In the Wild</h3>
<p>You can see a complete example of this in action in my simple <a href="http://github.com/jsankey/droidscope">DroidScope</a> Android application.  The custom runner is applied in the droidscope-test application in the test/ subdirectory.  You can even see the <a href="http://pulse.zutubi.com/browse/projects/droidscope/builds/latest/tests/default/">test results</a> being picked up by Pulse on our demo server.  Note that some of the tests are <a href="/2010/07/06/android-testing-using-pure-unit-tests/">pure unit tests</a>, which are run on a regular JVM, whereas others are run with the custom runner on an emulator.  It&#8217;s nice for all the results to be collected together!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.alittlemadness.com/2010/07/14/android-testing-xml-reports-for-continuous-integration/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Android Testing: Using Pure Unit Tests</title>
		<link>http://www.alittlemadness.com/2010/07/06/android-testing-using-pure-unit-tests/</link>
		<comments>http://www.alittlemadness.com/2010/07/06/android-testing-using-pure-unit-tests/#comments</comments>
		<pubDate>Tue, 06 Jul 2010 08:06:01 +0000</pubDate>
		<dc:creator>Jason</dc:creator>
				<category><![CDATA[Agile]]></category>
		<category><![CDATA[Android]]></category>
		<category><![CDATA[Build]]></category>
		<category><![CDATA[Continuous Integration]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Testing]]></category>

		<guid isPermaLink="false">http://www.alittlemadness.com/?p=667</guid>
		<description><![CDATA[Introduction
The Android SDK comes with support for testing, allowing tests to be run on an Android device (or emulator) via instrumentation.  This is useful for functional tests that require a realistic environment, but for the majority of tests it is overkill.  The instrumentation and emulation layers add complexity to the process, making tests [...]]]></description>
			<content:encoded><![CDATA[<h3>Introduction</h3>
<p>The Android SDK comes with support for <a href="http://developer.android.com/guide/topics/testing/testing_android.html">testing</a>, allowing tests to be run on an Android device (or emulator) via instrumentation.  This is useful for functional tests that require a realistic environment, but for the majority of tests it is overkill.  The instrumentation and emulation layers add complexity to the process, making tests much slower to run and harder to debug.</p>
<p>The good news is that there is no need to run most of your tests via instrumentation.  Because Android applications consist of regular Java code, it is possible to isolate much of the implementation from the Android environment.  In fact, if you&#8217;ve separated concerns in your application already, it&#8217;s likely that large parts of it are already independent of the Android APIs.  Those sections of your code can be tested on a regular JVM, using the rich ecosystem of tools available for unit testing.</p>
<h3>Unit Testing Requirements</h3>
<p>To put this idea into practice, I set out the following requirements for unit testing my Android application:</p>
<ol>
<li>The unit tests should run on a regular JVM, with no dependency on the Android APIs or tools.</li>
<li>It should be possible to run the tests within Eclipse.</li>
<li>It should be possible to run tests using Ant.</li>
<li>Running tests via Ant should produce reports suitable for use with a Continuous Integration server.</li>
</ol>
<p>These requirements allow the tests to be run quickly within the development environment, and on every commit on a build server.</p>
<h3>Adding a Unit Testing Project</h3>
<p>In keeping with my existing <a href="/setting-up-an-android-project-build/">Android project setup</a>, I decided to use an additional  project specifically for unit testing.  To recap, in the original setup I had two projects:</p>
<ol>
<li>The main project: containing the application itself.</li>
<li>The test project: containing an Android test project for instrumentation testing, in a test/ subdirectory of the root.</li>
</ol>
<p>Both projects had Ant build files and Eclipse projects.  Similar to the use of a test/ subdirectory for instrumentation tests, I added my new unit test project in a unit/ subdirectory of the root.  As with the other projects, the source code for the unit tests lives in a src/ subdirectory, giving the following overall layout:</p>
<pre class="brush: plain;">my-app/
    src/        - main application source
    test/
        src/    - functional tests
    unit/
        src/    - unit tests</pre>
<p>Creating the Eclipse project for unit testing was trivial: I just added a new Java Project named <b>my-app-unit</b>.  I then edited the build path of this project to depend on my main <b>my-app</b> project, so that I could build against the code under test.</p>
<h3>Testing Libraries</h3>
<p>The main tool required for this setup is a unit testing framework.  I decided to go with <a href="http://junit.org/">JUnit 4</a> as it is well supported in Eclipse, Ant and CI servers.  (JUnit is also used by the instrumentation testing support in the Android SDK.)  In addition, for mocking I am a fan of <a href="http://mockito.org/">Mockito</a>.  Note, though, that the beauty of using pure Java tests is you can use any of the myriad of mocking (and other) libraries out there.</p>
<p>For consistency with the existing projects, I added the JUnit and Mockito jars to a libs/ subdirectory of the unit project.  I then added those jars to the build path of my Eclipse project, and I was ready to implement some tests!</p>
<h3>A Trivial Test</h3>
<p>To make sure the setup works, you can try adding a trivial JUnit 4 test case:</p>
<pre class="brush: java;">package com.zutubi.android.myapp;

import static org.junit.Assert.*;

import org.junit.Test;

public class MyAppTest
{
    @Test
    public void testWorld()
    {
        assertEquals(2, 1 + 1);
    }
}</pre>
<p>If all is well you should be able to run this in Eclipse as a JUnit test case.  Once you have this sanity test passing, you can proceed to some Real Tests.</p>
<h3>Adding an Ant Build</h3>
<p>Setting up an Ant build took a little more effort than for the original projects, as their build files import Android rules from the SDK.  For the unit tests, I wrote a simple build file from scratch, trying to keep within the conventions established by the Android rules:</p>
<pre class="brush: xml;">&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;project name=&quot;my-app-unit&quot; default=&quot;test&quot;&gt;
    &lt;property name=&quot;source.dir&quot; value=&quot;src&quot;/&gt;
    &lt;property name=&quot;libs.dir&quot; value=&quot;libs&quot;/&gt;

    &lt;property name=&quot;out.dir&quot; value=&quot;build&quot;/&gt;
    &lt;property name=&quot;classes.dir&quot; value=&quot;${out.dir}/classes&quot;/&gt;
    &lt;property name=&quot;reports.dir&quot; value=&quot;${out.dir}/reports&quot;/&gt;
    &lt;property name=&quot;tested.dir&quot; value=&quot;..&quot;/&gt;
    &lt;property name=&quot;tested.classes.dir&quot; value=&quot;${tested.dir}/build/classes&quot;/&gt;
    &lt;property name=&quot;tested.libs.dir&quot; value=&quot;${tested.dir}/libs&quot;/&gt;

    &lt;path id=&quot;compile.classpath&quot;&gt;
        &lt;fileset dir=&quot;${libs.dir}&quot; includes=&quot;*.jar&quot;/&gt;
        &lt;fileset dir=&quot;${tested.libs.dir}&quot; includes=&quot;*.jar&quot;/&gt;
        &lt;pathelement location=&quot;${tested.classes.dir}&quot;/&gt;
    &lt;/path&gt;

    &lt;path id=&quot;run.classpath&quot;&gt;
        &lt;path refid=&quot;compile.classpath&quot;/&gt;
        &lt;pathelement location=&quot;${classes.dir}&quot;/&gt;
    &lt;/path&gt;

    &lt;target name=&quot;clean&quot;&gt;
        &lt;delete dir=&quot;${out.dir}&quot;/&gt;
    &lt;/target&gt;

    &lt;target name=&quot;-init&quot;&gt;
    	&lt;mkdir dir=&quot;${out.dir}&quot;/&gt;
    	&lt;mkdir dir=&quot;${classes.dir}&quot;/&gt;
    	&lt;mkdir dir=&quot;${reports.dir}&quot;/&gt;
    &lt;/target&gt;

    &lt;target name=&quot;-compile-tested&quot;&gt;
        &lt;subant target=&quot;compile&quot; buildpath=&quot;${tested.dir}&quot;/&gt;
    &lt;/target&gt;

    &lt;target name=&quot;compile&quot; depends=&quot;-init,-compile-tested&quot;&gt;
        &lt;javac target=&quot;1.5&quot; debug=&quot;true&quot; destdir=&quot;${classes.dir}&quot;&gt;
            &lt;src path=&quot;${source.dir}&quot;/&gt;
            &lt;classpath refid=&quot;compile.classpath&quot;/&gt;
        &lt;/javac&gt;
    &lt;/target&gt;

    &lt;target name=&quot;run-tests&quot; depends=&quot;compile&quot;&gt;
        &lt;junit printsummary=&quot;yes&quot; failureproperty=&quot;test.failure&quot;&gt;
            &lt;classpath refid=&quot;run.classpath&quot;/&gt;

            &lt;formatter type=&quot;xml&quot;/&gt;

            &lt;batchtest todir=&quot;${reports.dir}&quot;&gt;
                &lt;fileset dir=&quot;${source.dir}&quot; includes=&quot;**/*Test.java&quot;/&gt;
            &lt;/batchtest&gt;
        &lt;/junit&gt;

        &lt;fail message=&quot;One or more test cases failed&quot; if=&quot;test.failure&quot;/&gt;
    &lt;/target&gt;
&lt;/project&gt;</pre>
<p>The <b>run-tests</b> target in this build file compiles all of the unit test code against the libraries in the unit test project, plus the classes and libraries from the project under test.  It then runs all JUnit tests in classes that have names ending with <b>Test</b>, printing summarised results and producing full XML reports in build/reports/.  These XML reports are ideal for integrating your results with a CI server (<a href="http://zutubi.com/products/pulse/">Pulse</a> in my case, of course!).</p>
<h3>Wrap Up</h3>
<p>The Android SDK support for testing is useful for functional tests, but too slow and cumbersome for rapid-feedback unit testing.  However, there is nothing to stop you from isolating the pure Java parts of your application and testing them separately.  In fact this is one of those rare win-wins: by clean design of your code you also get access to all the speed and tool support of testing on a regular JVM!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.alittlemadness.com/2010/07/06/android-testing-using-pure-unit-tests/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Android Functional Testing vs Dependency Injection</title>
		<link>http://www.alittlemadness.com/2010/06/29/android-functional-testing-vs-dependency-injection/</link>
		<comments>http://www.alittlemadness.com/2010/06/29/android-functional-testing-vs-dependency-injection/#comments</comments>
		<pubDate>Tue, 29 Jun 2010 08:04:28 +0000</pubDate>
		<dc:creator>Jason</dc:creator>
				<category><![CDATA[Agile]]></category>
		<category><![CDATA[Android]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Testing]]></category>

		<guid isPermaLink="false">http://www.alittlemadness.com/?p=654</guid>
		<description><![CDATA[I commonly use Dependency Injection (DI) to create testable Java code.  Dependency injection is simple: instead of having your objects find their own dependencies, you pass them in via the constructor or a setter.  One key advantage of this is the ability to easily substitute in stub or mock dependencies during testing.
Naturally, as [...]]]></description>
			<content:encoded><![CDATA[<p>I commonly use <a href="http://jamesshore.com/Blog/Dependency-Injection-Demystified.html">Dependency Injection</a> (DI) to create testable Java code.  Dependency injection is simple: instead of having your objects find their own dependencies, you pass them in via the constructor or a setter.  One key advantage of this is the ability to easily substitute in stub or mock dependencies during testing.</p>
<p>Naturally, as I started working on an Android application, I tried to apply the same technique.  Problems arose when I tried to combine DI with the Android SDK&#8217;s <a href="http://developer.android.com/guide/topics/testing/testing_android.html">Testing and Instrumentation</a> support.  In particular, I am yet to find a suitable way to combine DI with functional testing of Android activities via <a href="http://developer.android.com/reference/android/test/ActivityInstrumentationTestCase2.html">ActivityInstrumentationTestCase2</a>.  When testing an activity using the instrumentation support, injection of dependencies is foiled by a couple of factors:</p>
<ol>
<li>Constructor injection is impossible, as activities are constructed by the framework.  I experimented with various ways of creating the Activity myself, but was unable to maintain a connection with the Android system for true functional testing.</li>
<li>Setter injection is fragile, as activities are started by the framework as soon as they are created.  There is no time to set stub dependencies between the instantiation of the Activity and its activation.</li>
</ol>
<p>Not ready to give DI away, I scoured the web for existing solutions to this problem.  Although I did find some DI libraries with Android support (notably <a href="http://code.google.com/p/google-guice/wiki/OptionalAOP">Guice no AOP</a> and <a href="http://code.google.com/p/roboguice/">roboguice</a> which builds upon it), the only testing support I found was restricted to unit tests.  Although roboguice has support for Activities, it relies on being able to obtain a Guice Injector from somewhere &#8212; which just shifts the problem by one level of indirection.</p>
<p>Given how complex any DI solution was going to become (if indeed it is possible at all) I decided to step back and consider alternatives.  A classic alternative to DI is the Service Locator pattern: where objects ask a central registry for their dependencies.  Martin Fowler&#8217;s article <a href="http://martinfowler.com/articles/injection.html">Inversion of Control Containers and the Dependency Injection pattern</a> compares and contrasts the two patterns in some detail.  Most importantly: a Service Locator still allows you to substitute in different implementations of dependencies at test time.  The main downside is each class is dependent on the central registry &#8212; which can make them harder to reuse.  As I&#8217;m working with Activities that are unlikely to ever be reused outside of their current application, this is no big deal.</p>
<p>Implementation-wise, I went with the simplest registry that works for me.  I found it convenient to use my project&#8217;s <a href="http://developer.android.com/reference/android/app/Application.html">Application</a> implementation as the registry.  In production, the Application onCreate callback is used to create all of the standard dependency implementations.  These dependencies are accessed via simple static getters.  Static setters are exposed to allow tests to drop in whatever alternative dependencies they desire.  A contrived example:</p>
<pre class="brush: java;">public class MyApplication extends Application
{
    private static IService service;
    private static ISettings settings;

    @Override
    public void onCreate()
    {
        super.onCreate();
        if (service == null)
        {
            service = new ServiceImpl();
        }

        if (settings == null)
        {
            SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
            settings = new PreferencesSettings(preferences);
        }
    }

    public static IService getService()
    {
        return service;
    }

    public static void setService(IService s)
    {
        service = s;
    }

    public static ISettings getSettings()
    {
        return settings;
    }

    public static void setSettings(ISettings s)
    {
        settings = s;
    }
}</pre>
<p>I access the dependencies via the registry in my Activity&#8217;s onCreate callback:</p>
<pre class="brush: java;">
public class MyActivity extends Activity
{
    private IService service;
    private ISettings settings;

    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);

        service = MyApplication.getService();
        settings = MyApplication.getSettings();

        setContentView(R.layout.main);
        // ...
    }

    // ...
}
</pre>
<p>And I wire in my fake implementations in my functional test setUp:</p>
<pre class="brush: java;">
public class MyActivityTest extends ActivityInstrumentationTestCase2&lt;MyActivity&gt;
{
    private MyActivity activity;

    public MyActivityTest()
    {
        super(&quot;com.zutubi.android.example&quot;, MyActivity.class);
    }

    @Override
    protected void setUp() throws Exception
    {
        super.setUp();
        MyApplication.setService(new FakeService());
        MyApplication.setSettings(new FakeSettings());
        activity = getActivity();
    }

    public void testSomething() throws Throwable
    {
        // ...
    }
</pre>
<p>After all of the angst over DI, this solution is delightful in its simplicity.  It also illustrates that static is not always a dirty word when it comes to testing!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.alittlemadness.com/2010/06/29/android-functional-testing-vs-dependency-injection/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Pulse Continuous Integration Server 2.2 Beta!</title>
		<link>http://www.alittlemadness.com/2010/05/20/pulse-continuous-integration-server-2-2-beta/</link>
		<comments>http://www.alittlemadness.com/2010/05/20/pulse-continuous-integration-server-2-2-beta/#comments</comments>
		<pubDate>Thu, 20 May 2010 06:50:20 +0000</pubDate>
		<dc:creator>Jason</dc:creator>
				<category><![CDATA[Agile]]></category>
		<category><![CDATA[Continuous Integration]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Testing]]></category>
		<category><![CDATA[Zutubi]]></category>

		<guid isPermaLink="false">http://www.alittlemadness.com/?p=509</guid>
		<description><![CDATA[Great news: today the latest incarnation of Pulse, version 2.2, went beta!  In this release we&#8217;ve focused primarily on usability, largely in the build reporting UI.  A new build navigation widget allows you to easily step forwards and backwards in your build history &#8211; while sticking to the same build tab.  All [...]]]></description>
			<content:encoded><![CDATA[<p>Great news: today the latest incarnation of <a href="http://zutubi.com/products/pulse/">Pulse</a>, version 2.2, went beta!  In this release we&#8217;ve focused primarily on usability, largely in the build reporting UI.  A new build navigation widget allows you to easily step forwards and backwards in your build history &#8211; while sticking to the same build tab.  All of the build tabs themselves have been overhauled with new styling and layout.  Here&#8217;s a sneak peak at the artifacts tab, for example:</p>
<div id="attachment_510" class="wp-caption aligncenter" style="width: 473px"><a href="http://www.alittlemadness.com/wp-content/uploads/artifacts-tab.png"><img src="http://www.alittlemadness.com/wp-content/uploads/artifacts-tab.png" alt="Artifacts Tab" title="artifacts-tab" width="463" height="233" class="size-full wp-image-510" /></a><p class="wp-caption-text">Artifacts Tab</p></div>
<p>It not only shows additional information, with greater clarity, but also allows you to sort and filter artifacts so you can find the file you are after.  Other UI changes go beyond style too &#8211; for example the new build summary tab shows related links and featured artifacts for the build.  More information, and screenshots, are available on the <a href="http://zutubi.com/products/pulse/new/">new in 2.2</a> page.</p>
<p>We&#8217;ve also squeezed in some less obvious updates, such as:</p>
<ul>
<li>The much-requested ability to move projects and agents in the template hierarchy.</li>
<li>Convenient navigation up and down the template hierarchy.</li>
<li>The ability to subscribe to projects by label.</li>
<li>An option to use subversion exports for smaller and faster builds.</li>
<li>Improved cleanup of persistent working directories (when requesting a clean build).</li>
<li>Performance improvements for large configuration sets.</li>
</ul>
<p>The first beta build, Pulse 2.2.0, is available for <a href="http://zutubi.com/products/pulse/downloads/">download</a> now.  We&#8217;d love you to give it a spin and let us know what you think!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.alittlemadness.com/2010/05/20/pulse-continuous-integration-server-2-2-beta/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Zero To Continuous Integration in Three Minutes</title>
		<link>http://www.alittlemadness.com/2010/04/12/zero-to-continuous-integration-in-three-minutes/</link>
		<comments>http://www.alittlemadness.com/2010/04/12/zero-to-continuous-integration-in-three-minutes/#comments</comments>
		<pubDate>Mon, 12 Apr 2010 07:37:54 +0000</pubDate>
		<dc:creator>Jason</dc:creator>
				<category><![CDATA[Agile]]></category>
		<category><![CDATA[Build]]></category>
		<category><![CDATA[Continuous Integration]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Testing]]></category>
		<category><![CDATA[Zutubi]]></category>

		<guid isPermaLink="false">http://www.alittlemadness.com/?p=487</guid>
		<description><![CDATA[A large part of our focus with Pulse revolves around saving time.  We started Pulse with the belief that it shouldn&#8217;t be so hard to set up a continuous integration server, nor should it take so much effort to maintain.  With that in mind, I&#8217;ve highlighted the main ways we achieve simplicity and [...]]]></description>
			<content:encoded><![CDATA[<p>A large part of our focus with <a href="http://zutubi.com/products/pulse/">Pulse</a> revolves around saving time.  We started Pulse with the belief that it shouldn&#8217;t be so hard to set up a continuous integration server, nor should it take so much effort to maintain.  With that in mind, I&#8217;ve highlighted the main ways we achieve simplicity and maintainability in Pulse in two new demo videos:</p>
<ul>
<li><a href="http://zutubi.com/products/pulse/videos/setup/">Getting Started With Pulse</a>: in which I start from scratch, installing Pulse, adding a new project and running a first build in under three minutes.  By watching the video, you&#8217;ll see that it is unabridged, and I did nothing but follow the simple steps laid out in front of me.</li>
<li><a href="http://zutubi.com/products/pulse/videos/templates/">Templated Configuration</a>: in which I demonstrate how Pulse&#8217;s unique templated configuration system saves you time configuring and (especially) maintaining your continuous integration server.  Templates make CI <a href="http://en.wikipedia.org/wiki/Don't_repeat_yourself">DRY</a>.</li>
</ul>
<p>We focus on saving time simply because it adds a lot of value to Pulse.  Our customers tell us that simplicity, maintainability and dedicated support are the main reasons they chose <a href="http://zutubi.com/products/pulse/">Pulse</a> to manage their builds.  <a href="http://zutubi.com/products/pulse/downloads/">Give it a go</a> yourself: you can get started in no time <img src='http://www.alittlemadness.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> .</p>
]]></content:encoded>
			<wfw:commentRss>http://www.alittlemadness.com/2010/04/12/zero-to-continuous-integration-in-three-minutes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Article: Optimise Your Acceptance Tests</title>
		<link>http://www.alittlemadness.com/2010/03/09/article-optimise-your-acceptance-tests/</link>
		<comments>http://www.alittlemadness.com/2010/03/09/article-optimise-your-acceptance-tests/#comments</comments>
		<pubDate>Tue, 09 Mar 2010 04:43:02 +0000</pubDate>
		<dc:creator>Jason</dc:creator>
				<category><![CDATA[Agile]]></category>
		<category><![CDATA[Build]]></category>
		<category><![CDATA[Continuous Integration]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Testing]]></category>

		<guid isPermaLink="false">http://www.alittlemadness.com/?p=483</guid>
		<description><![CDATA[In a similar vein to my previous post, I&#8217;ve revived some old posts about acceptance testing &#8212; and made significant additions. The end result is a new article:
Many developers have a love-hate relationship with automated acceptance tests. One major sticking point is the time acceptance tests take to execute, which can easily cause a blow [...]]]></description>
			<content:encoded><![CDATA[<p>In a similar vein to my <a href="/2010/02/22/article-testing-is-a-developers-perspective/">previous post</a>, I&#8217;ve revived some old posts about acceptance testing &#8212; and made significant additions. The end result is a new article:</p>
<blockquote><p>Many developers have a love-hate relationship with automated acceptance tests. One major sticking point is the time acceptance tests take to execute, which can easily cause a blow out of project build times. In this article I&#8217;ll review 7 successful techniques we&#8217;ve put to work in our own projects to optimise our acceptance testing.</p></blockquote>
<p>You can read the full article at <a href="http://zutubi.com/products/pulse/articles/optimise-your-acceptance-tests/">zutubi.com</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.alittlemadness.com/2010/03/09/article-optimise-your-acceptance-tests/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Article: Testing Is &#8230; A Developer&#8217;s Perspective</title>
		<link>http://www.alittlemadness.com/2010/02/22/article-testing-is-a-developers-perspective/</link>
		<comments>http://www.alittlemadness.com/2010/02/22/article-testing-is-a-developers-perspective/#comments</comments>
		<pubDate>Mon, 22 Feb 2010 03:48:23 +0000</pubDate>
		<dc:creator>Jason</dc:creator>
				<category><![CDATA[Agile]]></category>
		<category><![CDATA[Opinion]]></category>
		<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://www.alittlemadness.com/?p=479</guid>
		<description><![CDATA[I&#8217;ve been planning for some time to package up a couple of my earlier series&#8217; of blog posts into a more digestible form.  Finally, I&#8217;ve taken the time to combine, edit and publish the Testing Is &#8230; series as a single article:
Arguments in favour of automated software testing are too often presented in a [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been planning for some time to package up a couple of my earlier series&#8217; of blog posts into a more digestible form.  Finally, I&#8217;ve taken the time to combine, edit and publish the <a href="/2007/02/14/testing-is-instant-gratification/">Testing Is &#8230;</a> series as a single article:</p>
<blockquote><p>Arguments in favour of automated software testing are too often presented in a patronising fashion. Developers that don&#8217;t write their own tests are labelled as &#8220;unprofessional&#8221; and the code they write as &#8220;worthless&#8221;. These arguments conflate two very different groups of developers: those who don&#8217;t care enough to test, and those that care deeply but are unconvinced of the benefits of testing. The former group aren&#8217;t worth convincing, and the latter can&#8217;t be expected to be swayed by an argument that insults them in this fashion.</p></blockquote>
<p>Read the full article on <a href="http://zutubi.com/products/pulse/articles/testingis/">zutubi.com</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.alittlemadness.com/2010/02/22/article-testing-is-a-developers-perspective/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Pulse 2.1.11: Get More From Your Build Agents</title>
		<link>http://www.alittlemadness.com/2009/12/16/pulse-2-1-11-get-more-from-your-build-agents/</link>
		<comments>http://www.alittlemadness.com/2009/12/16/pulse-2-1-11-get-more-from-your-build-agents/#comments</comments>
		<pubDate>Tue, 15 Dec 2009 18:17:16 +0000</pubDate>
		<dc:creator>Jason</dc:creator>
				<category><![CDATA[Agile]]></category>
		<category><![CDATA[Build]]></category>
		<category><![CDATA[Continuous Integration]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Testing]]></category>
		<category><![CDATA[Zutubi]]></category>

		<guid isPermaLink="false">http://www.alittlemadness.com/?p=463</guid>
		<description><![CDATA[The latest Pulse 2.1 beta build, 2.1.11, has just been freshly baked.  This build includes several new features and improvements.  Prominent among them is a new &#8220;statistics&#8221; tab for agents.  This tab lists various figures such as the number of recipes the agent executes each day and how long the average recipe [...]]]></description>
			<content:encoded><![CDATA[<p>The latest <a href="http://zutubi.com/products/pulse/">Pulse</a> 2.1 beta build, 2.1.11, has just been freshly baked.  This build includes several new features and improvements.  Prominent among them is a new &#8220;statistics&#8221; tab for agents.  This tab lists various figures such as the number of recipes the agent executes each day and how long the average recipe keeps the agent busy.  Statistics are also shown for agent utilisation, including a pie chart that makes it easy to visualise:</p>
<p><a href="http://www.alittlemadness.com/wp-content/uploads/agent-utilisation-chart.png"><img src="http://www.alittlemadness.com/wp-content/uploads/agent-utilisation-chart.png" alt="agent utilisation chart" title="agent utilisation chart" width="410" height="415" class="aligncenter size-full wp-image-464" /></a></p>
<p>This allows you to see if you are getting the most out of your agent machines.  If you do notice a machine is underutilised, another new feature could help identify the cause: compatibility information for projects and agents.  Pulse matches builds to agents by considering if the resources required for the project are all available on the agent.  Now when you configure requirements, Pulse shows you which agents those requirements are compatible with.  On the flip side, when configuring an agent&#8217;s available resources, Pulse shows you which projects those resources satisfy.</p>
<p>Other highlights in this build:</p>
<ul>
<li>Optional compression of large build logs (on by default).</li>
<li>Visual indicators of which users are logged in, and last access times for all users.</li>
<li>Support for Subversion 1.6 working copies for personal builds.</li>
<li>Actions can now be performed on all descendants of a project or agent template (e.g. disable all agents with one click).</li>
<li>New options to terminate a build early if a critical stage or number of stages have already failed.</li>
<li>The system/agent info tabs now show the Pulse process environment (visible to administrators only).</li>
<li>Use of bare git repositories on the Pulse master to save disk space.</li>
</ul>
<p>Yes, we have been busy <img src='http://www.alittlemadness.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .  Get over to our website and <a href="http://zutubi.com/products/pulse/downloads/">download</a> the beta now &#8212; it&#8217;s free to try, and a free upgrade for customers with current support contracts!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.alittlemadness.com/2009/12/16/pulse-2-1-11-get-more-from-your-build-agents/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
