0

Here is what we are tying to do:

  1. Create a new test via REST API with test type as Automated[Generic] and making sure the test definition field is populated as required(classpath+'.'+class name). Let's assume the test key for this test is MYPROJ-999.

  2. We run the automated test and generate Junit xml report.xml for the same test which was created in #1.

  3. We post the result using REST API.

curl -H "Content-Type: multipart/form-data" -u user:pwd -F "file=@report.xml" https://jira.my.com/rest/raven/1.0/import/execution/junit?projectKey=MYPROJ

Expected Result:

The result for MYPROJ-999 should be updated with PASS/FAILED and a new Test Execution issue should be created. No new test should be created.

Actual Result:

The API is creating a new test instead of updating the existing test MYPROJ-99.

Interesting observation is, if we create the test using Jira UI instead of using REST API, it works fine. No duplicate test is created.

As far as we can tell, the test created via UI and the test created via REST API, they look exactly the same. So, we are not able to understand, why the test created via API is behaving differently.

srinathbharadwaj
  • 125
  • 2
  • 13

2 Answers2

0

After lot of debugging, I found the root cause and it is so trivial but causes big issue. Not sure if this is a bug??

Anyways, here is the thing.

When we create a test of type Automated[Generic] using Jira app UI or the test gets created via import results API, the test definition field holds the value of classpath+'.'+classname value, but with a space in the beginning of the text.

But when I was creating a test via create issue api endpoint and I was populating the definition field, I was not giving a space at the beginning of classpath+'.'+classname value because I was not even aware that Jira/Xray adds a space in the beginning.

So, I tested by giving a space to the test definition field in the json payload and creating a test and then trying to import the results for the same test, I see that duplicate test is not created.

srinathbharadwaj
  • 125
  • 2
  • 13
0

the space at the beginning of the Generic Definition field that holds that unique identifier isn't normal. Please report it as a bug :)

Sérgio
  • 1,777
  • 2
  • 10
  • 12
  • Consider posting this as a comment instead of an answer. After gaining certain number of reputation points you will be able to post comments to other questions/answer. – Rahul Bhobe Jul 31 '20 at 18:18