0

Here's my current code to return all the TFS Test Case work items that have attachments, from a specific project:

public IEnumerable<ITestCase> TestCasesWithAttachments(ITestManagementTeamProject project)
{
    return
        project.TestCases.Query("SELECT [Id], [Title] FROM WorkItems WHERE State<>'Closed'")
        .Where(tc => tc.Attachments.Count > 0);
}

This not efficient because it is checking the attachment count using Linq on the result of the query.

Is there any way to check for test cases with a nonzero attachment count in the WIQL string itself?

I've tried things like SELECT [Id], [Title] FROM WorkItems WHERE State<>'Closed' AND AttachmentCount<>0 to no avail...

Matthew Watson
  • 104,400
  • 10
  • 158
  • 276

1 Answers1

2

You need to have the following code:

project.TestCases.Query("SELECT [id], [title] FROM WorkItems WHERE [System.AttachedFileCount]>0 ");
Vicky - MSFT
  • 4,970
  • 1
  • 14
  • 22