Search code examples
tfs

Using TFS Api, how to create a test case?


I would like to use the TFS Api to create a test case and this test case should belong to a certain test suite obviously.

I have found the method:

var testCase = project.TestCases.Create();

While that method seems logical, I have no idea where the test will end up being attached to the project rather than the suite.

I'm looking for a concise example on how to create a test case using the TFS Api.


Solution

  • So after some digging I found what looks like a code sample:

    ITestCase tc = proj.TestCases.Create();
    tc.Title = "Verify X when doing Y";
    tc.Save();
    
    // Now let's add that testcase
    newSuite.Entries.Add(tc);
    
    // Now let's save the plan (don't need to explicitly
    // save test suites).
    plan.Save();