Quick tip – link up tests and tracker issues

How do you associate a unit (or integration) test with the bug tracker issue it intends to fix ?

The usual approach is to use comments in the test code:

//fix issue raised by bug tracker item 2554
public void someTest(){
       ...
}

This works… but can be fairly verbose. A cleaner approach is simply to annotate each test with the relevant tracker issue.

First create the annotation:

import java.lang.annotation.ElementType;
import java.lang.annotation.Target;

@Target(ElementType.METHOD)
public @interface Tracker{
   int value;
}

and then use it to tag each test with the relevant tracker number:

@Tracker(2554)
public void someTest(){
  ...
}
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s