måndag 12 oktober 2009

FitNesse revisited

I recently wrote about FitNesse saying that our goal was to allow domain experts to get on with testing while the developers could concentrate on building new features.

Wrong. Wrong. Wrong.

What I should have said was that the key to acceptance testing with FitNesse is collaboration. Testers and developers should work together when writing tests and developing features. This is what FitNesse makes possible.

Testing will always come at a cost. The trick is to make sure the returns exceed this cost. Junit has made this possible for unit testing.

When it comes to acceptance testing, the cost-benefit relationship is not so clear. FitNesse can swing the balance in favour of automation. So here's my revised list of tips for how to do this:
  1. Collaborate when creating acceptance tests. Developers and testers should be encouraged to work together.
  2. Create separate FitNesse fixtures for setting up test data, exercising the SUT, and making assertions on the result.
  3. Names are important. The readability of your test cases will improve.
  4. Write unit tests for your fixtures. Their design will benefit.
  5. Keep your tests independent. Intra test dependencies will lead to tears.
  6. Use dependency injection. Decoupled fixtures can be reused more easily.
  7. Document your fixtures. This will help you write clear test cases.
  8. Think carefully about logging. Debugging will be less painful.

torsdag 10 september 2009

Pythagoras moment

Monday evening was spent discussing retrospectives with fellow members of the Swedish Scrum User Group. I came away from the evening with a few new ideas but it wasn't until a couple of days later that I had a pythagoras-in-the-bath moment.

But first more about Monday. Once again we used the Open Space format for this get together. As Harrison Owen puts it:

Open Space Technology is effective when real learning, innovation, and departure from the norm are required. When you aren't quite sure where you are, and less than clear about where you are headed, and require the best thinking and support from all those who wish to be involved, Open Space Technology will provide the means.

Hold your horses! Isn't that also a perfect description of a retro. A bunch of enthusiasts getting together to come up with imaginative solutions to tricky problems. Why use open space just to discuss retros when open space can be used to do a retro? Eureka! Now I know how I'm going to do our next retro.

torsdag 3 september 2009

Retrospective serendipity

If we hadn’t run out of time at our latest retrospective then I wouldn’t have discovered SurveyMonkey.com.

We usually end our retros by dot voting on a list of suggested improvements. This time the retro had been particularly fruitful – lots of interesting discussions and a dozen improvement suggestions. And then our time ran out.

With various team members already heading off to their next meetings I rashly promised to send out an internet based survey so that we could at least prioritize our improvements list before the afternoon’s planning session.

And then I started to wonder if I’d promised too much. With no time to do an in depth market analysis and after a quick google I selected SurveyMonkey. A choice I wasn't going to regret. 15 minutes later the survey was sent out and in the following planning meeting we had a nicely prioritized list of suggested improvements.

It worked so well that I think we’ll do it this way again – even if we don’t run out of time in our retrospective.

tisdag 1 september 2009

Scrumming for Britain

As a scrum master I sometimes find it useful to compare what I do with coaching a sports team. Recently I was given the opportunity to put this theory into practice when I was invited to coach a national team at the World Orienteering Championships.

One of the most important jobs of a scrum master is to ensure that the day to day work of the team runs smoothly. Above all a happy team is a productive team. Likewise a happy team of athletes will get better results. So this was one of my main targets when going into the World Championships – shield the runner’s from any external problems and create a positive atmosphere.

You might think that a coach would spend most of his time telling the athletes what to do. But for a team of experienced international athletes there’s not an awful lot new to tell them. In fact I found myself working more like a facilitator – stimulating discussions, and encouraging the athletes to come up with their own solutions for handling the race situations. Very scrum masterish!

Of course there are differences too. Running a major championship is more comparable to releasing a system rather than working in scrum sprints. Though this is just what the athletes do in the run up to a major race. Using short, medium and long term goals they work incrementally towards the big release date.

So how did it go? No medals this time but some successes as well as a few disappointments. Now I hope there will be a chance to do a retrospective with the team – I’m sure that would help them get better results next time. And help me to do a better job, if I’m asked to help again.

onsdag 29 juli 2009

Fitnesse refactored

We have put a lot of effort into automated testing. Not just unit testing but also system testing with Fitnesse. But it has come at a cost. In particular creating and maintaining our Fitnesse fixtures has become a burden.

In theory, Fitnesse should enable our domain specialists to write tests while the developers can get on with developing the features.

So far we haven't reached this nirvana.

For each major new feature we find ourselves either having to change our current fixtures or develop new ones. This taxes our development resources and our system tests lag behind development instead of leading it.

We must be able to do better than this.

Recently I've been wrestling with our fixtures - refactoring them to reduce the development debt. Finally they're starting to smell a little sweeter.

Here are some principles which have guided me ("best practices" if you like)

Principle 1. Structure fitnesse tests like unit tests.

They should have three distinct sections:
  • setup the test data
  • exercise the code to be tested
  • perform assertions on the result
Principle 2 (corollory to Principle 1) Create separate fixtures for each of these phases.

One fixture say for priming the database with data. Another fixture for performing a query. And a third fixture for checking the result of the query.

Principle 3. Names are important.

By taking advantage of "graceful names" and choosing method names carefully our tests become more readable. They now look lke this:

|object id | is in query result? |
instead of

|objectId | checkResult?|

Principle 4. Fixtures should be tested too.

Writing unit tests for fixture code speeds up development and improves the quality and design of the fixtures.

Principle 5. Use dependency injection to decouple fixtures.

We use Spring to inject database connections, JMS queues and domain specific beans into our fixtures.

Nothing too radical there of course. But hopefully by concentrating on these key practices the returns from our investment in Fitnesse will improve.

tisdag 9 juni 2009

Service Registry Manifesto

How should you go about creating a service registry? I've been working on this recently and the more I dig into it, the more I agree with the ideas expressed by Martin Fowler when he wrote about a Humane Registry.

Inspired by this article and also the Agile Manifesto I came up with a service registry manifesto. Namely, we should value:

  • clarity and conciseness over detail and completeness
  • flexibility and expandability over specification and planned structure
  • integration with existing sources over creation of new content
  • encouragement of use over contractual restrictions

That is, while there is value in the items on the right, we value the items on the left more.

Coincidentaly, after I created my manifesto, MF himself gave his seal of approval for using this type of list when he blogged on Comparative Values.

måndag 1 juni 2009

Sniffing out success

Recently, I found myself discussing code smells with a colleague. How do you recognise them and how can you fix them? Reading about refactoring and design patterns is certainly one way to train your olfactory sensitivity. But study alone is not enough.

In a previous life I was an elite orienteer. When I was racing to the limits of my ability one of the key success factors was reacting to mistakes and correcting them before they caused time loss. A bit like fixing code smells really. Nipping small mistakes in the bud before they grow into major time wasters.

As an orienteer I learned early in my career that the key to perfecting this skill is training, training and training. I'm convinced this is also true for the programmer. Mastering the skill of sniffing out code smells and cleaning them up comes only with practice - lots of it.

And just like the very best athletes, you should never be really satisfied. Skills need to be maintained with constant training, and there's always always room for improvement.