Link to home
Start Free TrialLog in
Avatar of ChristoferDutz
ChristoferDutzFlag for Germany

asked on

Extending JUnit? / Linking JUnit and Jira?

Hi,

I am currently trying to extend JUnit. What I would like to do, is to create an Annotation that sets a Jira issue to "resolved" as soon as the test method succeeds. I was thinking of something like:

@JiraTest(issueId="XYZ-223")
public
void TestMethodForIssueXYZ223()
{
      // THE TEST CODE TESTING FOR ISSUE XYZ-223
}

Is there any way of extending JUnit in this way, or would I have to hack it in there somehow?
Is there another way, I haven't thought of, for implementing this type of functionality? ( I Hope so )
Is there allready a tool that provides this type of functionality? ( I doubt it, since I was Googling for such a tool for several hours )

Chris
Avatar of Mick Barry
Mick Barry
Flag of Australia image

annotations aren't going to help you with that
and what you are trying does not make sense. typically the issue would be resolved once tested, not just because the unit test passed. The test could well pass but the issue not be fixed.

Avatar of ChristoferDutz

ASKER

We are currently extending our Feature and Issue Tracking.

Our goal is it to add a testcase specification for Bugs or Features as Sub-Issues in our issue tracker. As soon as a dvelpers starts working on an issue, he implements a unit-test for testing this functionality and the JUnit extension should take care of seting the issue status. This functionality should only be available when run on our continuous integration server. We want to implement the thing to automatically reopen an issue, if a previously successfull test fails because of recent changes. By this we can see the progress of a Project directly in Jiras diagrams.

In the meanwhile I managed to find out, that I have to create a custom test runner class and explicitly using this runner by using the
@RunWith(IntegrationTestIgnorer.class)
By using the Jira SOAP extensions I should be able to achieve, what I want.
>  that I have to create a custom test runner class and explicitly using this runner by using the
@RunWith(IntegrationTestIgnorer.class)
By using the Jira SOAP extensions I should be able to achieve, what I want.

thats right, you need something that will process your annotation to perform the jira update.


interwsting idea, must give it some more thought :)

updating jira should be the easy part.

Ok ... I finally got all parts together.

On the one side, you have to turn on the Jira SOAP interface.
I am now creating a JUnit Runner usint some help from these sites:
http://schuchert.wikispaces.com/CustomJunit4RunnerJUnit4_4
http://blog.nominet.org.uk/tech/2008/08/26/writing-a-custom-junit-45-test-runner/

And then I am using the Jira SOAP client tool described on:
http://confluence.atlassian.com/display/JIRAEXT/JIRA+Maven2+SOAP+Library

to communicate with my Jira. Hope I'll have it finished soon ;-)
SOLUTION
Avatar of Mick Barry
Mick Barry
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
For all that might be interested ... Having a look at the Perl implementation on:
http://confluence.atlassian.com/display/JIRA/Creating+a+SOAP+Client
Gave me the clue at how to Update an issues workflow ;-) (Don't look at the Java stuff ... it's a read-only-example)