I am sorry if this is already answered but I could not find this question in the community.
Here is what we are tying to do:
1. Create a new test via app with test type as Automated[Generic] but entering Summary & Test Definition. We are entering the test definition as test script path('.' separated)+summary. Let's assume the test key for this test is MYPROJ-999.
2. We then create a Test Plan and include this test in the test plan.
3. We run the automated test and generate Junit xml report.xml
4. We post the result using REST API with POST method.
curl -H "Content-Type: multipart/form-data" -u user:pwd -F "email@example.com" https://jira.my.com/rest/raven/1.0/import/execution/junit?projectKey=MYPROJ^&testPlanKey=MYPROJ-702400178
The result for MYPROJ-999 should be updated with PASS/FAILED under the Test Plan. No new test should be created.
The API is creating a new test under the Test Plan. The existing test MYPROJ-999 is not updated instead a new test created.
I do not know if this helps but I have made further observations. So, as you all know, we can create test multiple ways as listed below.
#1 Create a new test using Jira UI by selecting test type as Automated[Generic] & then run cURL command to import results
#2 Create a new test using REST API by setting test type as Automated[Generic] & then run cURL command to import results
#3 Create a new test by cloning an automated test which got created as a results of importing results from REST API & then run cURL command to import results
As far as I can tell, there is no difference between the test which I create via UI and the test which I am creating via REST API. They look exactly the same. This is #2 scenario where it is creating duplicate test.
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.
To clarify some points, when you are importing JUnit execution results and you don't have the Tests for these results, previously created on your Jira (we try to find it using the Generic test Definition field), Xray will try to create the Tests. If you have required fields for the issue type Test, Xray is not able to create the Tests.
JUnit’s Test Cases are identified by the pair of attributes “classname” and “name” attributes. Test Cases are imported to Xray’s Generic Test issues, and the “classname” and “name” attributes are concatenated and mapped to the Generic Test Definition field of the Generic Test.
If a Test already exists with the same Generic Test Definition, then it is not created again.
Hello @José Domingues _Xpand IT_ ,
Have one more question on the same lines. I have parameterized methods due to which now my test case will have 'n' entries with "name" attribute having brackets and the parameters in it. How to handle this kind of situation when importing JUnit results? Because the test remains the same just the parameters fed to the test differs
Connect with like-minded Atlassian users at free events near you!Find an event
Connect with like-minded Atlassian users at free events near you!
Unfortunately there are no Community Events near you at the moment.Host an event
You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events