I have assembled the Triforce

Recently I put in the final piece of a mini project I’d been thinking about for a while.  I made a change to an Agent Ralph source file and committed it to my Mercurial repo.  Within about a minute I was browsing the MbUnit test results.  Now that may not sound very exciting, but it is.  It is because all of this was conducted online, through my browser, on a pc that didn’t have Mercurial, Visual Studio, or any development tools whatsoever.  I was coding in the cloud, baby.

Now with Agent Ralph I have boiled my unit tests down to the point where they are just code snippets.  Adding a new test case is as simple as dropping a csharp file into a directory.  It is automatically picked up and fed into a test harness, which parses the code and gets all Ralphy on it.  Here’s a sample, right out of the repo:

using System;
namespace AgentRalph.CloneCandidateDetectionTestData
    public class CloneInForeachBlock
        void Target()
            foreach (int i in new int[] { })
                /* BEGIN */
                /* END */

        private void Expected()

This sample comes from the CloneCandidateDetectionTestData folder.  Any file in that folder is assumed to hold a class containing at least two methods, Target and Expected.  Target is scanned for clones, and the test passes if a clone is found that matches Expected AND consists of all the code between the START and END ‘markup’ embedded in the comments.   Thanks to the magic of MbUnit’s generative tests each code file appears as it’s own test, as if each were a method with it’s own [Test] attribute.  So you see, whipping up new tests is crazy easy.

Occasionally an idea for a test case will come to me, and it’s usually when I’m at a place where I have no access to Agent Ralph code.  Like work.  Typically I’d make some notes in an email and code it up when I got home.  It got me thinking, I don’t really need Visual Studio and the whole dev setup to create these test cases.  They’re just simple code snippets, scraped out of a directory.  I could be scraping them from anywhere, like off a wiki even.  The next thought of course was to run that test automatically.  How could I put this all together?

Building and running tests is easy, any continuous integration server would do.  I chose TeamCity, which we’ve been using at work and is just great.  I can’t say enough nice things about it.  For this mini-project, it’s easy third party report integration and build artifact downloading features were exactly what I wanted.  A little dyndns magic and I had it online.  My MbUnit tests look pretty nice I think.

At some point I stumbled across Bespin.  Bespin is a Mozilla project that “proposes an open extensible web-based framework for code editing”.  It’s a web based, code centric text editor, and more.  One part of the more is version control integration.  Mercurial is supported, which is what I use for Agent Ralph.  I can pull down the code, hack on it, and push changes back out to the Google code hosted repository, all right in the browser.  There’s the missing piece, my editor.

And of course, Google Code is the glue that brings them together.

And there you have it, coding in the cloud!  This graphic ought to help you fully grasp the awesomeness.


3 Responses to “I have assembled the Triforce”

  1. Ranji writes:

    Hello Josh,

    I have found Agent Ralph very useful and my team is using it extensively. Could you please add support to ReSharper 6.x as we have upgraded to ReSharper 6.x?

    Thanks and Regards

  2. josh writes:

    Hi Ranji,

    I love hearing that your team is using Agent Ralph.

    I’ll see if I can get Agent Ralph updated for the latest R# soon.


  3. josh writes:

    Hi Ranji, I wanted to let you know that I’ve released an update to Agent Ralph. It now runs on R#8. Thanks, Josh

Leave a Reply