Reputation: 31
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.
Upvotes: 1
Views: 3946
Reputation: 76670
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.
Upvotes: 3