Postman collection that checks if your tasks in Azure DevOps were closed.
Postman is a tool that allows us to test, consume and debug the REST API, a very interesting feature that it also has is that we can write automated tests, it is one of the most used tools for testing among other things.
We import the collection and the environment
- Get your personal access token
- Detail your organization
- Indicate the project of your preference
- Choose a team
- Check tasks!!!
A personal access token (PAT) is used as an alternate password to authenticate in Azure DevOps, the collection needs the token to avoid authentication problems.
Fortunately, the process to obtain it is very well detailed in the following link
Note: When you create the token, you can specify some permissions, this could cause inconvenience, or you can choose "Full Access" for testing purposes only.
Now that we have our token, we must detail which is our organization, this can be found by visiting your Azure DevOps and you must place it in the following environment variable.
To be able to choose the project you want, you must execute "Get Projects" and review the answer, you may have many, once you see the project you want, you must copy its id and place it in the following environment variable.
To be able to choose the team, you must execute "Get Project Teams" and review the answer, the teams that you will see will be from the project that you previously indicated, once you see the group you want, you must copy its id and place it in the following environment variable.
Finally now that we have completed the organization, the project and the team, it is time to start the review process.
We must click on "Review", choose the option "Run" and start the process.
And we will see the results.
With a couple of clicks we can know which tasks we have not closed, the process may be somewhat extensive, but we can still improve it.
Thank you very much!
Some adjustments you might need:
- For custom iteration use [System.IterationPath] = '{{projectName}}\\Iteration_name'
This use case requires you to make some changes to the Check items request.
- In Params add the following value to the list of fields Microsoft.VSTS.Scheduling.OriginalEstimate
- In Tests replace the script with the following, you can adjust it if you require it
var status = pm.environment.get("validateStatus")
var jsonData = JSON.parse(responseBody)
var all_items = jsonData.value
var day = 5
var hour = 8
var completed = 0.0
var estimate = 0.0
for (const item in all_items) {
data = all_items[item]
identifier = data.id
fields = data.fields
completed += fields["Microsoft.VSTS.Scheduling.CompletedWork"]
estimate += fields["Microsoft.VSTS.Scheduling.OriginalEstimate"]
pm.test(identifier+" status", () => {
pm.expect(fields["System.State"]).to.eql(status);
});
}
pm.test("Estimate:"+String(estimate)+" - complete:"+String(completed), () => {
pm.expect(completed).to.be.gte(hour*day);
});
This project would not be possible without:
- https://www.postman.com/
- https://learning.postman.com/docs/sending-requests/managing-environments/
- https://learning.postman.com/docs/sending-requests/variables/
- https://azure.microsoft.com/es-es/services/devops/
- https://docs.microsoft.com/en-us/rest/api/azure/devops/?view=azure-devops-rest-6.1
- https://docs.microsoft.com/en-us/azure/devops/integrate/how-to/call-rest-api?view=azure-devops