Monthly Archives: November 2007

Configuring email notifications for CruiseControl.NET

I gotten a few emails asking how I to setup email notifications for builds running under CruiseControl.NET. Here is a section from one of the ccnet.config files I’m using on a CruiseControl.NET server:

1 <publishers> 2 <statistics /> 3 <xmllogger /> 4 5 <email from="fromaddr@here.com" mailhost="192.168.1.14" 6 mailhostPassword="pwd" mailhostUsername="username" 7 includeDetails="true"> 8 <users> 9 <user name="Steve Trefethen" address="stevet@nospam.com" 10 group="NotifyGroup" /> 11 </users> 12 <groups> 13 <group name="NotifyGroup" notification="failed" /> 14 </groups> 15 </email> 16 </publishers>

Nothing unusual except of course for changing some of the more obvious details. 🙂

Mozilla's Prism making web apps first class citizens on the desktop

Mozilla Labs Prism

I’m a big fan of Mozilla applications and lately my attention has turned to Prism. It’s an incredibly simple idea which allows web applications to become first class citizens on the desktop. Prism is really just a single pane web browser with no menu or toolbar. Sounds a bit strange at first but when pointed at Gmail or Google Calendar or whatever your favorite web app is it releases that application from its tabbed browser confines and brings it onto your desktop as a top level window. What’s great is that for each application you point it at it maintains window size and location making it feel more like a client application.

Mozilla Prism options dialog

To setup a new application with Prism all you do is launch it and fill out this simple dialog. You have options to create the standard shortcuts and provide your own application name. It’s available for Windows, Mac and Linux so be sure to give it a shoot.

I’ve already created several shortcuts to applications I used all the time like GMail and Google Calendar. I haven’t run into any issues yet but I’ll admit I’ve toyed with the idea of implementing my own version of the same thing, just because.

And be sure to read the blog post about it which has all the details.

Kudos to the guys/gals at Mozilla for this latest app!

Organizing your build process

In this, my second post in a series on automated testing, I’m going to talk about a few steps you’ll need to take after your team has committed to automation. Diving into the deep end and immediately writing a bunch of tests isn’t the place to start. Organizing your project, preparing your code base and planning for automation are the first priorities. Of course, the assumption here is that you’re adding automation after the fact.

Organizing your build

If your project isn’t easy to build you’ve identified the first thing that needs fixing. Having a repeatable automated build is key to a successful test automation strategy. Essentially, getting your build organized means the following two things:

  • Version control
  • Continuous Integration

Version Control

Subversion

The first step to organizing your build and preparing it for continuous integration is to make sure it’s under version control. There are lots of ways to implement version control but it’s the first step to repeatability which is what test automation is all about. Personally, I really like SubVersion otherwise known as SVN, and would highly recommend it particularly if you’re just starting out. There’s been plenty written about the benefits of version control so I won’t go into that here just make your choice and get your code checked in.

Build Automation

The next step is automating your build process. Jeff Atwood wrote The F5 Key Is Not a Build Process discussing the benefits of moving your build process beyond your IDE of choice and I couldn’t agree more. Build automation is really going to be the key to successful test automation. When changes are committed to your repository a build gets kicked off and subsequently launches your test automation. With this setup you’re automation is guaranteed to run against every change to your repository immediately notifying you when a change has “broken” the build.

Note: Make sure your team understands that a break in test automation that’s kicked off as part your continuous integration process is as bad as checking in a syntax error. Yeah, read that again. Even if the code builds, if the smoke test fails as a result of the check-in it should be treated as though a syntax error were checked in.
cruisecontrol.net

For continuous integration I’m a fan of CruiseControl.NET but as with source control you have a lot of choices. CruiseControl.NET is open source and includes a web dashboard that’s easy to modify and supports writing plugins making it easy to extend the build system. Its rather light on documentation so if you don’t want get your hands a little dirty I’d recommend something like Automated Build Studio from AutomatedQA.

 

Putting it all Together

If you find this to be a bit daunting, have no fear I’ve put together a 10 minute video that demonstrates this entire process from beginning to end for a simple project. Of course, your project will be more complex but you’ll get a feel for how easy it is to get going. Note, I made this video in April ’07 while still employed at Borland which is no longer the case nonetheless the video is still relevant.

Previous entries in this series:

Other related posts I’ve written:

Facebook Developer Toolkit v1.3 Starter Kit updated

UPDATED Nov. 6, 2008: A new release is available here.

I’ve updated my Facebook Starter Kit to version 1.3 of the Facebook Developer Toolkit published by Microsoft available on CodePlex. I also cleaned up the code and moved the Appkey and Secret so their read from web.config.

Btw, I’ve had a few questions in email about how to fetch a friend list which can be done as follows:

if (!IsPostBack)
{
System.Collections.ObjectModel.Collection
<User> userinfo = _fbService.GetUserInfo(_fbService.UserId); Label1.Text = "Hi, " + userinfo[0].FirstName;
Image1.ImageUrl
= userinfo[0].PictureUrl.ToString();

// Use the FacebookService Component to populate Friends System.Collections.ObjectModel.Collection<User> Friends =
_fbService.GetFriends();
for (int i = 0; i < Friends.Count; i++)
DropDownList1.Items.Add(Friends[i].FirstName.ToString());
}

If you haven’t seen it I’ve also created a starter kit for Nikil Kothari‘s Facebook.NET framework so be sure to take a look a that as well.

Enjoy!

Copyright and the Free Pascal project

Updated July 31, 2011 Another interesting battle brewing with regard to Open Source and copying of source code between Google and Oracle over Java.

If you’ve been following my blog recently perhaps you’re aware of activity related to a post I wrote back in September asking for a free version of the Delphi command line compiler. In a response to a comment asking if I’d ever tried the Free Pascal compiler I stated:

I haven’t tried the Free Pascal compiler for a number of reasons including the fact that it’s RTL/FCL violate Borland/CodeGear’s copyright. I’ve looked at the code closely and IMO copyright issues abound.

At that time, there were a few replies but over the last few days members of the Free Pascal core team as well as the FP community attacked me personally over this statement. Upon request I published one example illustrating my point using Classes.ExtractStrings. Unfortunately, this was met by further attacks until a comment from Marco van de Voort and subsequent email apology from Daniël Mantione, both members of the core Free Pascal team. The following republished with Daniël’s permission:

from: daniel.mantione@freepascal.org
to:strefethen@<deleted>
date:13 Nov 2007 15:25:14 -0800
subject:Weblog Mail from ‘Dani&#235;l Mantione’ on ‘Steve Trefethen’s Weblog’

Hello Steve,

I would like to offer apologies on behalf of the Free Pascal development team for the aggressive comments on your weblog. The situation puzzles us; that code you showed is more similar than one would expect with an independend implementation, yet it doesn’t look like being taken from Delphi source. Michael, who comitted it, cannot remember having written it so it might have been contributed by someone, but searches through e-mail archives haven’t revealed anything yet.

Anyway, it’s good that this is on the agenda now. Copyrights are something we have to be carefull about.

Best regards,

Daniël Mantione

In further support my statements I added five additional examples all from classes.pp which covers roughly 16% of that file, which is not exactly a “fringe file”. I’ll add that this more recent review took but a few minutes and is by no mean extensive nor exhaustive unlike a review I did earlier this year. Daniël has since provided me plausible explanations as to how these issues might have arisen and indicated that the core team is reviewing sysutils.pp and classes.pp.

Unfortunately, this is neither a new issue nor limited to sysutils.pp and classes.pp. I’m disappointed that seemingly no one from the Free Pascal team or community discovered nor, to my knowledge, raised these issues years ago.

And, fwiw, I haven’t been employed by Borland since June 28, 2007 nor, as was implied in a comment, do I have any financial interest in the company whatsoever.

Of course, this raises the issue of how do you go about validating the originality of Open Source source code in general? And no, I don’t have a good answer.

Automated testing advice – making the commitment

Over the years I’ve spent a great deal of time writing test automation and I’ve learned a lot along the way. The road to successful automation has lots of steps, some small some large. I’m going to start a series of posts talking about my experience with test automation dating back to 1994 when I got my first serious taste.

Commit to automated testing

Ensure that everyone in your team who you want involved in test automation is committed to its success. If you can’t do that then you’re looking at an up hill battle that commit themselves to building and maintaining a automated test environment consider the battle lost.

Team Commitment

For automated testing to succeed you have to gain buy-in from all the involved parties and through hard work validate that automation can benefit everyone. Here are some of the initial things you’ll need to get your team to commit to:

  • Learning about software testing
  • Buying, building or finding open source tools your people can embrace for use in automation
  • Monitoring the success of the testing efforts
  • Developing a smoke test
  • Sharing the responsibility of maintaining the smoke test
  • Creating a command line build for your project(s)
  • Publishing test results

Individual Commitment

As an individual contributor if you’re not willing to commit time and effort to learn and assist with your team’s test automation efforts you’re undermining the process.

  • Always considering how your code will be tested
  • Learning the tools and techniques available to test your code
  • Writing tests for your own code
  • Run the smoke test before checking in
  • Understanding how changes you make will impact existing tests

Of course, these aren’t exhaustive but if you can’t accomplish these tasks the likelihood of succeeding will dwindle rapidly. I’ll look to expand on a number of these items.

Let’s face it, test automation can be hard and convincing people that it can save them time and effort can be equally difficult. If you’re team isn’t already on the testing bandwagon then you’re likely in a situation where you’re going to have to prove that automation can work before you’ll receive greater buy-in so be prepared to go it alone in the beginning. Committing to automated testing, in particular, convincing your clients and management may be a difficult task so be prepared.

What sort of problems have you run into getting people to commit to test automation?

My only MacBook Pro complaint – the squared off keyboard edge

MacBook Pro keyboard edgeWhile I really enjoy working on the MacBook Pro there is what I consider a rather annoying design flaw which really bothers me and I’m not alone, here too. The front edge of the keyboard where your wrists hits closest to your body is a sharp squared off edge that I’m finding that that really wears on the tender bottom side of my wrists. In contrast, the outside edges of the machine are all rounded and very smooth.

I’m a long time fan of the split Microsoft Natural Keyboard Pro and require upside down “T” arranged arrow keys as well as the layout of the Home/End/Insert/Delete/PGUP/PGDN keys and when at home that’s the keyboard I use. In fact, I’ve collected a few of them because Microsoft no longer produces this exact keyboard. For me, Jeff Atwood nails keyboard issues in this podcast from Scott Hanselman. Aside from this one issue I’m really enjoying the machine and Vista still runs well though I can’t say I’m thrilled with Vista.

Processing CSV files in C# using Open Source FileHelpers Library


Scott Hanselman recently posted about parsing CSV files from PowerShell and while I found it interesting I didn’t find the solution to be intuitive though perhaps that’s just me. I’ve recently purchased PowerShell in Action by Bruce Payette and I like the idea of PowerShell though I find myself bailing back to a plain old Command Prompt quite frequently. Anyway, a few days ago I blogged about using the Open Source FileHelpers library for parsing fixed and delimited length files. I thought it might be fun to tackle Scotts problem and see just how difficult it would be to duplicate his solution in C#. Here is what he was parsing (at least a snippet of it anyway):

“File”,”Hits”,”Bandwidth”
“/hanselminutes_0026_lo.wma”,”78173″,”163625808″
“/hanselminutes_0076_robert_pickering.wma”,”24626″,”-1789110063″
“/hanselminutes_0077.wma”,”17204″,”1959963618″
“/hanselminutes_0076_robert_pickering.mp3″,”15796″,”-55874279″
“/hanselminutes_0078.wma”,”14832″,”-1241370004″
“/hanselminutes_0075.mp3″,”13685″,”-1840937989″
“/hanselminutes_0075.wma”,”12129″,”1276597408″
“/hanselminutes_0078.mp3″,”11058″,”-1186433073″

With FileHelpers the first thing to do is define a class that maps the data in your file which for Scott’s data would look something like this:

    [DelimitedRecord(“,”)]

    class Show

    {

        public string Filename;

        [FieldConverter(typeof(IntConverter))]

        public Int32 downloads;

        [FieldConverter(typeof(IntConverter))]

        public Int32 bandwidth;

    }

Notice the class attribute indicates the separator used. Also notice the member attributes that provide string conversion for the integer values read from the file. Since the integers, unfortunately, have quotes the stock FileHelpers converter won’t work though that’s easily solved by writing a new IntConverted like this:

    public class IntConverter : ConverterBase

    {

        public override object StringToField(string from)

        {

            if (from != “” || from != “\”\“”)

                return Convert.ToInt32(from.Substring(1, from.Length – 2));

            else

                return string.Empty;

        }

    }

For parsing the file we use FileHelpers DelimitedFileEngine like this:

     DelimitedFileEngine e = new DelimitedFileEngine(typeof(Show));

     e.Options.IgnoreFirstLines = 1;

     object[] shows = e.ReadFile(“c:\\shows.txt”);

This creates an instance of the engine passing our Show class type with an option to ignore the first line of the file (the one with column headings). Calling ReadFile parses it into and array of Show objects populated with the data. Next, we’ll change the filename to the episode number using Scott’s regex and sort the data both using anonymous delegates:

    Regex regex = new Regex(“\\d{2}(?=[_.])“);

    Array.ForEach((Show[])shows, delegate(Show one)

        { one.Filename = regex.Match(one.Filename).ToString(); }

    );

    Array.Sort((Show[])shows, delegate(Show one, Show two)

   &nb
sp;    { return one.Filename.CompareTo(two.Filename); }

    );

Finally, we sum the downloads and print the data. Note this for loop modifies the array using the first instance of an episode to aggregate the total downloads, perhaps not optimal but gets the job done:

    Show sh = (Show)shows[0];

    for (int i = 1; i < shows.Length; i++)

    {

        if (((Show)shows[i]).Filename.CompareTo(sh.Filename) == 0)

            sh.downloads += ((Show)shows[i]).downloads;

        else

        {

            Console.WriteLine(“{0,-4} {1,-6}”, sh.Filename, sh.downloads);

            sh = ((Show)shows[i]);

        }

    }

    Console.WriteLine(“{0,-4} {1,-6}”, sh.Filename, sh.downloads);


So, what’s the point? Well, at the end of Scott’s post he wrote:

It took less time than it would take to write a C# program and it’s easily modified ad-hoc.

Armed with FileHelpers this took no time at all, the bulk of the code is spent working with the data not importing into a usable form. Another point is, IMO the C# code is considerably easier to read. I’m finding that getting my head around PowerShell commands to be a bit awkward. For me PowerShell is tantilizingly powerful but I feel requires a different enough mind set to perhaps thwart rapid adoption. I can empathize with all those people who have “been meaning to try…” Of course, I suppose if we all had the chance to sit down with Lee Holmes things might be different.