Test Management for Jira Server

Annotations with Other CI Tools/Running Locally

If you are using Cucumber, setup could not be more simple. Add Test Management for Jira annotations to your Cucumber tests, and use our pre-made script to send the results to Jira. The integration is based on the JSON output files generated by Cucumber, so this output option needs to be configured properly, as follows.

annotations 01
  1. Configure the JSON output format for your automated tests on the TestRunner class. Here we’ve added JUnit and Cucumber output formats:

    @RunWith(Cucumber.class)
    @CucumberOptions(
    features = "src/test/resources/calculatorFeatures"
    ,glue={"com/adaptavist/tm4j/cucumberExample/stepDefinition"}
    ,plugin = {"junit:target/cucumber/result.xml", "json:target/cucumber/calculator.json"}
    )
  2. Annotate your automated tests with the @TestCaseKey tag.

    The @TestCase(key = "JQA-T1") annotation maps the test method to an existing test case in Test Management for Jira by matching its key. The @TestCase(name = "Sum Two Numbers") annotation adds a name to the test case. This maps this test method to an existing test case in Test Management for Jira by matching its name. If the test case doesn’t exist in Test Management for Jira, then a new one can be automatically created using this name when the results are uploaded.

    Scenarios can be mapped to test cases in Test Management for Jira by using the test-case key or name as a scenario tag.

    For example: @TestCaseKey=ABC-T123.

To Annotate a Cucumber Test

Feature: Calculator


  @TestCaseKey=ABC-T123
  Scenario: Add a number
    Given a calculator I just turned on
    And I add 4 and 4
    Then the result is 8

To Annotate a JUnit Test

public class CalculatorSumTest {


    @Test
    @TestCase(key = "JQA-T1")
    public void sumTwoNumbersAndPass() {
        Calculator calculator = new Calculator();
        assertEquals(5, calculator.sum(3, 2));
    }

    @Test
    @TestCase(key = "JQA-T2")
    public void sumTwoNumbersAndFail() {
        Calculator calculator = new Calculator();
        assertNotEquals(2, calculator.sum(1, 2));
    }

    @Test
    public void notMappedToTestCaseAndPass() {
        Calculator calculator = new Calculator();
        assertEquals(3, calculator.sum(1, 2));
    }

    @Test
    @TestCase(name = "Mapped to a Test Case Name and Pass")
    public void mappedToATestCaseNameAndPass() {
        Calculator calculator = new Calculator();
        assertEquals(4, calculator.sum(2, 2));
    }

}

Now you can run the tests with Maven test, and the Test Management for Jira test execution results file will generate in the same execution folder.

Scripts for Local Testing/Other CI Tools

Add the following scripts to your project if you want to run automated tests locally.

For running automated tests with other CI tools, add this script as a task/script within the tool itself to run after the build.

#!bin/bash

When using JUnit with the custom output file provided by the Test Management for Jira JUnit Listener:

zip output_results.zip tm4j_result.json
curl --basic --user user:pass -F "file=@output_results.zip"
{your-jira-base-url}/rest/atm/1.0/automation/execution/{projectKey}?autoCreateTestCases=false

When using Cucumber:

zip output_results.zip target/cucumber/*
curl --basic --user user:pass -F "file=@output_results.zip"
{your-jira-base-url}/rest/atm/1.0/automation/execution/cucumber/{projectKey}?autoCreateTestCases=false