Search code examples
testngjirajira-xray

Specifying the test plan for importing TestNG results into Jira has no effect


I'm trying to import TestNG results into Jira through the Multipart API (https://docs.getxray.app/display/XRAYCLOUD/Import+Execution+Results+-+REST#ImportExecutionResultsREST-TestNGXMLresultsMultipart).

My Test Exceution JSON looks like this:

{
    "fields": {
        "summary": "Test Execution for TestNG Execution",
        "project": {
            "key": "PVCON"
        }
    },
    "xrayFields": {  
         "testPlanKey": "PVCON-6288"
    }
}

But the resulting test execution is not associated with the test plan:

enter image description here

I was using the simpler version of the API (https://docs.getxray.app/display/XRAYCLOUD/Import+Execution+Results+-+REST#ImportExecutionResultsREST-NUnitXMLresults) where the test plan key is passed as a query parameter, and that worked.


Solution

  • From your screenshot, you're using Xray server/datacenter and not Xray Cloud, that runs on Jira Cloud. The APIs are slightly different. For Xray server/DC you should use this documentation instead. The "xrayFields" attribute doesn't exist in the syntax for Xray server/DC.

    You should use something like the following, where you need to figure out the id of the "Test Plan" custom field in Jiraa (11807 in my case). To obtain it, you can ask you Jira admin that can easily see it whenever editing the custom field configuration.

    {
    "fields": {
        "project": {
            "key": "PVCON"
        },
        "summary": "Test Execution for nunit execution",
        "issuetype": {
            "name": "Test Execution"
        },
    
        "customfield_11807" : [ "PVCON-6288" ]
     }
    }