In TFS, how to find all test cases in a test suite with a query (C #)?

With Team Foundation Server, given the WorkItem of the “Test Suite” type, how can I write a query to select all the test cases associated with this test suite?

+5
source share
4 answers

Unfortunately, there are no references to work items created between test plans, plot and cases. Therefore, although they are work items, they have no links. This means that a default query is not possible.

Labeling of all test cases in the set with the package name works. Then you can use a query that filters work item tags .

You can go even further and automate tagging using Web Hooks and Azure Functions (or some other hosted API) magic. This allows you to create a web hook that listens for creation (or update) for test cases. Using some code mentioned in other posts, you can get a test suite of a test case, and then use the REST API to add it as a tag in the test case.

+2
source

You may need to use this ITestSuiteBase interface.

 AllTestCases Gets the read-only collection of test cases for this suite and all hierarchical children. TestCases Gets a read-only collection of test cases. 

Additional Information from MSDN

Here is a sample code:

 public static List<TestCase> GetAllTestCaseFromSuite(ITestPlan testPlan, int suiteId, bool includeExecutionStatus = true) { List<TestCase> testCases = new List<TestCase>(); testPlan.Refresh(); ITestSuiteBase currentSuite = testPlan.Project.TestSuites.Find(suiteId); currentSuite.Refresh(); foreach (var currentTestCase in currentSuite.TestCases) { TestCase testCaseToAdd = new TestCase(currentTestCase.TestCase, currentSuite, testPlan, includeExecutionStatus); if (!testCases.Contains(testCaseToAdd)) { testCases.Add(testCaseToAdd); } } log.InfoFormat("Load all test cases in the suite with Title= \"{0}\" id = \"{1}\"", currentSuite.Title, currentSuite.Id); return testCases; } 

You can find more information on this blog: TFS Test Case Management C # Code

+1
source

If you are using TFS 2015 or higher,

you can check this link:

If you are not using TFS 2015 or higher:

While there is no way to create a regular TFS request via the web interface, rather than calling an API or custom coding, to get a list of test cases that belong to a specific test suite. support-querying-for-all-test-cases-in-a-specifed

Or try the old tool: test-plans-test-suites-test-cases-mapping

0
source

"Show tests from child suites" is the option you want. To see a screenshot, click here . No need for inquiry. Since the option name indicates that it lists all the child tests from the package. To do this, you may need the TFS manager plugin.

0
source

Source: https://habr.com/ru/post/1241741/


All Articles