Linking your issues, with Serenity, JBehave and Jira – Part 1

with 5 Comments

This post is part of a series about Serenity BDD and JBehave.
Serenity BDD, formerly known as Thucydides, is an open source library designed to make practicing Behaviour Driven Development easier.
My current experience is in creating automated regression and acceptance tests using a combination of Serenity with JBehave.
In this post we will look at the one-way integration Serenity offers with Jira.

Integrating Serenity and Jira one-way

Although Serenity and Jira support two-way integration, in this post we are looking at a first simple attempt of one-way integration. Linking Jira issues from within your stories.
For this step we assume you already have Jira installed and some issues ready to link.

The first step is to create or update your serenity.properties file in your project root directory.

jira.url=http://myjiraserver
jira.project=PRJ
jira.username=jirauser
jira.password=t0pSecret

You can also set these properties up in your Maven pom.xml file or pass them in as system properties.

To link an issue to one of your stories, open or create a story and add the Meta tag @issue to that story

Meta:
@issue PRJ-38

Login
Narrative:
As a user I would like to login on the portal

Scenario: Login succesfully

It is also possible to link an issue to a specific scenario in your story

Meta:

Login
Narrative:
As a user I would like to login on the portal

Scenario: Login succesfully
Meta:
@issue PRJ-2

serenity-jira-testresult

serenity-jira-story-details

  • Eugenia Bokhan

    I have 2 projects in jira and I need to integrate them somehow with serenity.
    Is there any possibility to use 2 serenity.properties files or to mark jira.project?

    • schenkweb

      Assuming these 2 projects are on the same jira server and the user that
      is used to connect to Jira has the rights to view both projects,
      it looks like you could remove the jira.project property from your serenity.properties file for this to work.

      • Eugenia Bokhan

        Yeah, you right. But in that case we lose items “stories”, “features”, ets. And I need them to show the code coverage.
        I’m thinking about having 3 property files (one common and two with project’s names). Maybe it could work, if we create 2 profiles in pom.xml

        • schenkweb

          That could work. There are also two other things you could try. I haven’t tried it myself, but it should be possible to set the jira properties as systemPropertyVariables in your pom. Then you don’t need multiple property files, just set the correct systemPropertyVariables in the correct profile.

          Or, depending in how you include your stories in your pom…

          I use “StoryClasses” (a class file with the same name as my story name) which extends SerenityStory. In this class you could get and set serenity environment variables. Using this method you could set the correct jira project for each story individually.

          This could also work if you use a Testsuite class which extends SerenityStories, but then you must configure the way you find stories in your path the right way, to only find those stories that belong to the specified jira project (perhaps using meta filtering)


          import net.serenitybdd.jbehave.SerenityStory;

          public class MyTestStory extends SerenityStory {
          public MyTestStory() {
          String currentJiraProject = getEnvironmentVariables().getProperty("jira.project");

          getEnvironmentVariables().setProperty("jira.project", "projectX");
          }
          }

          • Eugenia Bokhan

            Nice
            Thanks for idea