Sunday, May 17, 2009

Sample Defect Tracking Link Widget for FitNese

WikiWidgets in FitNesse are a great way to extend the functionality of your FitNesse pages. Essentially they let you rewrite the content of you page in creative ways. My first forays into the creation of my own wiki widgets was to add some specially styled text to make things stand out on the page. This has been replaced by the new !style_class widget added by Uncle Bob a few releases back.

That doesn't mean there isn't a need for a widget now and then. I wanted to come up with a way to connect my wiki pages to our JIRA defect tracking and workflow system at work. I wanted it to be easy for me and my team to be able to do this with the smallest amount of wiki text. So I created a Widget for it !JIRA{TEAM-11111} which gets transformed into a proper link to the JIRA system.

I'm putting this out here for anyone who wants to reuse it. To make it work in your environment, you will need update the URL to match your environment. It can be further modified to work with any defect tracking system that supports URL as a way to access the system. And if you aren't using JIRA, and many of you probably are not, you can just rename the Widget as well.

    package common.wikitext.widgets;

import java.util.regex.Matcher;
import java.util.regex.Pattern;
import fitnesse.wikitext.WikiWidget;
import fitnesse.wikitext.widgets.ParentWidget;

public class JiraWikiWidget extends WikiWidget {
public static final String REGEXP = "!JIRA(\\{\\w+.*?\\})?";

public static final Pattern pattern = Pattern.compile(REGEXP);

private String originalText = "";

private String token = null;

public RpJiraWikiWidget(ParentWidget parent, String text) {
super(parent);
originalText = text;
Matcher match = pattern.matcher(text);
if (match.find()) {
token = match.group(1);
}
}

private String formatTestIdentifier(String text) {
String tempText = removeBraces(text);
return "<a class=\"dts\" "
+ "href=\"http://jiraserver/jira/browse/"
+ tempText + "\">" + tempText + "</a>";
}

private String removeBraces(String format) {
return format.replaceAll("\\{", "").replaceAll("\\}", "");
}

public String render() throws Exception {
return (token != null) ? formatTestIdentifier(token) : originalText;
}
}

It's not the trickiest code in the world. But it's yours to take and to use.

So far this is a small contribution to the community. At some point in the not too distant future I'll share my vim syntax coloring for FitNesse wiki pages. I still am looking to make a couple of improvements before that goes out.

Comments and questions are welcome.

Thursday, May 7, 2009

Phone? MP3 Player? Software Testing Tool?

So often the focus on tools in software testing is on automation of GUIs, web testing, or even unit testing. Sometimes you hear about a little tool that has a special purpose that is very focused, such as AllPairs or PerlClip (via Satisfice).

How about a tool that you carry in your pocket? The iPhone and iPod Touch have revolutionized the smart phone industry. And, while the app store isn't about to do the same to software testing, it is pretty interesting how a tester can occasionally benefit from having a multi-purpose tool like an iPhone or iPod Touch at hand.

So you ask, how can you use one to test? Let's explore a couple of common tools I like to have in my pocket for testing:

Safari
A web browser is always a handy tool. Assuming you can get on the network at the office with a Touch, or have an iPhone You can:
  • Look stuff up on Google.com
  • Try out your non-iPhone web application for usability on an iPhone
  • Kick off a FitNesse test (probably need wi-fi access for this one).
BigStopWatch (free)
I don't know about you, but I've often kept a stop-watch at hand to keep track of how long it takes for the software to do something. Having a reliable time piece to check loading time or responses can give you ammunition in a discussion later. Sometimes I haven't had that stop watch with me when I wanted it. Now I always have one with me. Technically I have one in my regular phone, but it is very clumsy.

Evernote (free)
Ubiquitous capture. That's what Evernote is good for. I use the Evernote client on my iPod Touch, my Windows computer and my Mac at home. If I had an iPhone, I could get pictures of the software behaving badly on someone else's computer. With my Touch, I can take notes in a meeting, at a co worker's desk or when I'm at lunch and have those notes for use later. You never know when inspiration will strike.

PCalc Lite Calculator (free)
A calculator is always a useful tool. Checking math is a common occurrence in testing. Sure, you could use the one in windows. But that thing is ancient. And it doesn't support RPN. OK, so i don't use the RPN option. I tried, but it didn't work. I'll try again later.

Read It Later (free)
Take your favorite Testing and Software Engineering thinkers with you. Don't be stuck with nothing to read when waiting in line for lunch. Catch up on Exploratory Testing, Agile Acceptance Testing, Scrum, or even what something neat from arstechnica. Either install the extension to Firefox or use a bookmarklet to select what you want to read later, and next time you sync up it will be waiting for you. There is a pay version that add some nice features. Instapaper is a nice alternative.

9-Toolbox (free)
Nothing like a handy tool that does the job of nine. Date calculator. Count-down clock (to release deadline or vacation?). Currency converter. And Unit conversion. All are nice to haves, though probably not infinitely useful.

Summary
So that's a list of some interesting options. By no means an exhaustive list. There are great ToDo apps, vim reference, html references, accessing safaribooksonline.com via the web, and it's even nice to use to listen to music while you work.

I love my iPod Touch. It is amazingly useful. Does everyone need one? No. Can't I do all of this with another tool, or even with paper? Yes. Is it the next place the tool vendors will go? I doubt it. Anyways, Apple won't allow capture-replay on the iPhone.

Now if no one beats me to it, I have an idea for an app.