One of my customers recently contacted me with a very specific problem. They were in a situation where they had created a large amount of test cases in the VSTS test area and they now needed to assign these test cases to several different suites in several different plans.
Obviously there is an option to do this through the UI, but it can be fairly longwinded (especially when going between plans).
We put together a script that allowed them to use the VSTS REST API and a comma separated values file to do this programatically instead.
This is what the source document looked like:
As you can see there is a column for the plan name, a column for the suite or suites (if they are in a tree structure) and a column for the case id(s). These IDs can be pulled out of the original (blueprint) plan/suite.
What the script does…
- Read in the CSV
- Step through the plans
- make sure every plan is only checked once
- check if it exists already
- if not, create it
- Step through each line
- run a recursive query to make sure the suite tree structure exists
- if the requested tree or parts of it do not exist, create the relevant suite(s)
- create an array of test cases (delimiter: “/”)
- check what test cases are assigned to the suite already
- assign those that are missing
I wrote my script using PowerShell
When would this be useful?
Whenever you have got a large set of test cases to assign to new plans or suites. (for example if you are putting together a new regression or UAT suite of manual tests)
Can I have a look at the script?
Sure. If you are looking to run this, make sure you are on the latest version of PowerShell.
You need a Personal Access Token to access the VSTS API. On premises you can use a PAT as well, but Integrated auth is also an option.