Can anyone please share the details how to create a test case in azure devops using rest api, preferably in python code. I couldn't find a direct API in azure devops but they shared an API for work item. But I don't have an idea how the body should be while creating a test case. Please suggest.
-
Regarding the body of the work item while creating test case is not mentioned anywhere. I have seen this example code for get projects but it would be great if anyone share a sample code to create a work item as test case with the exact body format. ThanksAhamed Sylo– Ahamed Sylo2020-10-03 09:22:36 +00:00Commented Oct 3, 2020 at 9:22
1 Answer
How to create test case in azure devops using rest api in python
The test case is also a work item. That is the reason why they shared an API for work item for you.
When you create a workitem with TestCase type:
Then we could find it display on the test case tab:
So, we could use the REST API Create a work item to create a workitem with Testcase type to create the test case:
PATCH https://{instance}/DefaultCollection/{project}/_apis/wit/workitems/${workItemTypeName}?api-version={version}
On the other hand, we could check the REST API about the Test cases, there are Get a test case, Delete a test case but no create the test case API directly.
To create a workitem in python, you could refer this official Azure DevOps Python API doc.
It contains Python APIs for interacting with and managing Azure DevOps. These APIs power the Azure DevOps Extension for Azure CLI. To learn more about the Azure DevOps Extension for Azure CLI, visit the Microsoft/azure-devops-cli-extension repo.
Here is some example code for creating work item in python.
You could check this thread for some more details.

