Hi All, Warm Regards, I have created test cases in JIRA test management tool. Automated the test cases using ready API. I want to update the test case status (Pass/Fail) Using jira rest api. Can some one pls help.
I referred the following link:
https://docs.atlassian.com/jira/REST/cloud/#api/2/workflowscheme-updateDraftDefault
Hi everyone,
This question is rather old, but I wanted to try to update the answers here. Natively, Jira does not do test management. There are however several plugins in Marketplace that can help make that a reality. A few that I am aware of are Zephyr, Xray, TM4J, and many more which you can find in a search of Marketplace.
I am not sure which one might have been referred to by 'Jira test management tool'. I am afraid that title is a bit vague to me, and sometimes plugins/apps can have their titles change in marketplace.
That said, because these apps add functionality to Jira, I don't have the expectation that Jira's native REST API will be able to manipulate these entities like standard Jira issue types. As such, it would be best to reach out to the plugin vendor to see if there does exist a REST API for managing these. I found some such as
I hope this helps. If not, it would probably be best to reach out to the specific plugin vendor for support on this topic.
Thanks
Andy
@rayudu you can update Test cases status in jira using Xray api if you have used X-ray to test management
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
12:52
To update the status of a test in a test execution in Jira using the Xray API, you'll need to follow these steps:
Get an Authentication Token: Xray API requires authentication. You need to generate a token using your Xray client ID and secret.
Update the Test Execution Status: Once you have the token, you can use it to update the status of a test within a test execution.
Here is a step-by-step guide:
Step 1: Get an Authentication Token
Send a POST request to the authentication endpoint with your client ID and secret.
Request:
sh
Copy code
curl -X POST "https://xray.cloud.getxray.app/api/v2/authenticate" \
-H "Content-Type: application/json" \
-d '{"client_id":"YOUR_CLIENT_ID","client_secret":"YOUR_CLIENT_SECRET"}'
Response:
json
Copy code
"YOUR_JWT_TOKEN"
Step 2: Update the Test Execution Status
Now, use the token to update the status of a specific test within a test execution.
Request:
sh
Copy code
curl -X POST "https://xray.cloud.getxray.app/api/v2/import/execution" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_JWT_TOKEN" \
-d '{
"testExecutionKey": "TEST_EXECUTION_KEY",
"tests": [
{
"testKey": "TEST_KEY",
"status": "STATUS"
}
]
}'
Parameters:
testExecutionKey: The key of the test execution.
testKey: The key of the test you want to update.
status: The new status for the test. It can be one of the following: PASS, FAIL, TODO, EXECUTING, ABORTED.
Example
Let's say you want to update test ABC-123 within test execution TE-456 to PASS. Here is what the request would look like:
sh
Copy code
curl -X POST "https://xray.cloud.getxray.app/api/v2/import/execution" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_JWT_TOKEN" \
-d '{
"testExecutionKey": "TE-456",
"tests": [
{
"testKey": "ABC-123",
"status": "PASS"
}
]
}'
Full Script Example
Here's a full example using Python and the requests library to automate the process:
python
Copy code
import requests
# Step 1: Authenticate and get the token
auth_url = "https://xray.cloud.getxray.app/api/v2/authenticate"
auth_payload = {
"client_id": "YOUR_CLIENT_ID",
"client_secret": "YOUR_CLIENT_SECRET"
}
auth_headers = {
"Content-Type": "application/json"
}
response = requests.post(auth_url, json=auth_payload, headers=auth_headers)
token = response.json()
# Step 2: Update the test execution status
execution_url = "https://xray.cloud.getxray.app/api/v2/import/execution"
execution_payload = {
"testExecutionKey": "TE-456",
"tests": [
{
"testKey": "ABC-123",
"status": "PASS"
}
]
}
execution_headers = {
"Content-Type": "application/json",
"Authorization": f"Bearer {token}"
}
execution_response = requests.post(execution_url, json=execution_payload, headers=execution_headers)
print(execution_response.status_code)
print(execution_response.json())
Make sure to replace YOUR_CLIENT_ID, YOUR_CLIENT_SECRET, TE-456, and ABC-123 with your actual Xray client ID, secret, test execution key, and test key respectively.
This script will authenticate with Xray, get a token, and then use that token to update the status of a test within a test execution.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Also, First i want to read the test cases which i have drafted in JIRA test management. Then want to update the test case status to PASS/FAIL using jira REST API.
Please do the needful.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi rayudu, How are you?
Are you able to update the status to PASS/FAIL using REST API now?
I want to do the same and not able to after searching for so long. I posted this question.
I am able to query using JQL as suggested but still not able to filter and update the status of my test execution
Hope to know how it went for you.
Thanks
Sam
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Gregor,
Thanks for reply.
Using post method:
https://xxxxxx/rest/api/2/issue/testcaseid/transitions?expand=transitions.fields
Payload:-
{
"update":{
"name": "In Progress",
"id": "3"
},
"transition": {
"id": "21"
}
}
Still not working
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Do you have any error message?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
To change issue status perform a transition.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Gregor,
The above link which u have shared is for changing the status of issue. Can you please share the details of how to change the execution status of any issue?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.