Skip to content

September 28, 2011

Thucydides Release 0.4.9 – improved issue tracking and JIRA integration

by jfsmart

A new version of Thucydides – version 0.4.9 – is now available in the Maven repositories. This release provides support for the new Selenium 2.6 ExpectedConditions (see here for details), and also focuses on new features for integration with your issue tracking system.

Thucydides can be configured to integrate with issue tracking systems such as JIRA and Trac. You specify this using the **thucydides.issue.tracker.url** system property. This property is the URL required to open a given issue, where the number of the issue is replaced by ‘{0}’, e.g.

http://my.jira.server/browse/MYPROJECT-{0}

To do this in Maven, you need to pass this system property to JUnit using the `maven-surefire-plugin` as shown here:

	<plugin>
	    <groupId>org.apache.maven.plugins</groupId>
	    <artifactId>maven-surefire-plugin</artifactId>
	    <version>2.7.1</version>
	    <configuration>
	        <systemPropertyVariables>
	            <thucydides.issue.tracker.url>http://my.jira.server/browse/MYPROJECT-{0}</thucydides.issue.tracker.url>
	        </systemPropertyVariables>
	    </configuration>
	</plugin>

For this to work correctly, you also need to configure the Thucydides Maven plugin with the issue tracking URL, as shown here:

            <plugin>
                <groupId>net.thucydides.maven.plugins</groupId>
                <artifactId>maven-thucydides-plugin</artifactId>
                <version>@project.version@</version>
                <configuration>
                    <jiraUrl>${jira.url}</jiraUrl>
                </configuration>
            </plugin>
Thucydides also provides special support for the Atlassian JIRA issue tracking tool. If you provide the **jira.url** system property instead of the **thucydides.issue.tracker.url**, you only need to provide the base URL for your JIRA instance, rather than the full path:
	<plugin>
	    <groupId>org.apache.maven.plugins</groupId>
	    <artifactId>maven-surefire-plugin</artifactId>
	    <version>2.7.1</version>
	    <configuration>
	        <systemPropertyVariables>
	            <jira.url>http://my.jira.server</jira.url>
	        </systemPropertyVariables>
	    </configuration>
	</plugin>  
        <plugin>
            <groupId>net.thucydides.maven.plugins</groupId>
            <artifactId>maven-thucydides-plugin</artifactId>
            <version>@project.version@</version>
            <configuration>
                <jiraUrl>${jira.url}</jiraUrl>
            </configuration>
        </plugin>

You need to provide the issue number. You can place this in the test title, prefixed by the ‘#’ character. For easyb tests, this just means mentioning the issue number (always starting with a ‘#’ character) somewhere in the scenario name. For JUnit tests, you use the **@Title** annotation as shown here:

	@RunWith(ThucydidesRunner.class)
	public class FixingAnIssueScenario {

	    @Managed
	    public WebDriver webdriver;

	    @ManagedPages(defaultUrl = "http://www.mysite.com")
	    public Pages pages;

	    @Steps
	    public SampleScenarioSteps steps;

	    @Title("Shopping cart should let users add multiple articles - fixes issues #123")
	    @Test
	    public void shopping_cart_should_let_users_add_multiple_articles() {
        	steps.add_item_to_cart("nuts");
        	steps.add_item_to_cart("bolts");
	        steps.cart_should_contain("nuts","bolts");
	    }
	}

Another way to specify issues in JUnit is to use the @Issue or @Issues annotations. You can use the @Issue annotation to associate an individual test with a specific issue

    @Issue("#123")
    @Test
    public void shopping_cart_should_let_users_add_multiple_articles() {
    	steps.add_item_to_cart("nuts");
    	steps.add_item_to_cart("bolts");
        steps.cart_should_contain("nuts","bolts");
    }

You can also place the @Issue annotation at the class level, in which case the issue will be associated with every test in the class:

@RunWith(ThucydidesRunner.class)
@Issue("#123")
public class FixingAnIssueScenario {

    @Managed
    public WebDriver webdriver;

    @ManagedPages(defaultUrl = "http://www.mysite.com")
    public Pages pages;

    @Steps
    public SampleScenarioSteps steps;

    @Test
    public void shopping_cart_should_let_users_add_multiple_articles() {
    	steps.add_item_to_cart("nuts");
    	steps.add_item_to_cart("bolts");
        steps.cart_should_contain("nuts","bolts");
    }

    @Test
    public void some_other_test() {
    	...
    }
}

If a test needs to be associated with several issues, you can use the @Issues annotation instead:

	@Issues({"#123", #456"})
	@Test
	public void shopping_cart_should_let_users_add_multiple_articles() {
		steps.add_item_to_cart("nuts");
		steps.add_item_to_cart("bolts");
	    steps.cart_should_contain("nuts","bolts");
	}

When you do this, issues will appear in the Thucydides reports with a hyperlink to the corresponding issue in your issue tracking system. These links will appear both in the story reports and the individual scenario reports, as illustrated here:

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

Note: HTML is allowed. Your email address will never be published.

Subscribe to comments

%d bloggers like this: