예제 #1
0
        /// <summary>
        /// Add test cases to an exisitng static test suite
        /// </summary>
        /// <param name="TeamProjectName"></param>
        /// <param name="TestPlanId"></param>
        /// <param name="StaticSuitePath"></param>
        /// <param name="TestCasesIds"></param>
        private static void AddTestCasesToSuite(string TeamProjectName, int TestPlanId, string StaticSuitePath, List <int> TestCasesIds)
        {
            int testSuiteId = GetSuiteId(TeamProjectName, TestPlanId, StaticSuitePath);

            if (testSuiteId == 0)
            {
                Console.WriteLine("Can not find the suite:" + StaticSuitePath); return;
            }

            TestSuite testSuite = TestPlanClient.GetTestSuiteByIdAsync(TeamProjectName, TestPlanId, testSuiteId).Result;

            if (testSuite.SuiteType == TestSuiteType.StaticTestSuite || testSuite.SuiteType == TestSuiteType.DynamicTestSuite)
            {
                List <SuiteTestCaseCreateUpdateParameters> suiteTestCaseCreateUpdate = new List <SuiteTestCaseCreateUpdateParameters>();

                foreach (int testCaseId in TestCasesIds)
                {
                    suiteTestCaseCreateUpdate.Add(new SuiteTestCaseCreateUpdateParameters()
                    {
                        workItem = new Microsoft.VisualStudio.Services.TestManagement.TestPlanning.WebApi.WorkItem()
                        {
                            Id = testCaseId
                        }
                    });
                }

                TestPlanClient.AddTestCasesToSuiteAsync(suiteTestCaseCreateUpdate, TeamProjectName, TestPlanId, testSuiteId).Wait();
            }
            else
            {
                Console.WriteLine("The Test Suite '" + StaticSuitePath + "' is not static or requirement");
            }
        }
        public TestSuite GetTestSuiteById()
        {
            string projectName = ClientSampleHelpers.FindAnyProject(this.Context).Name;
            // Get a testplan client instance
            VssConnection      connection     = Context.Connection;
            TestPlanHttpClient testPlanClient = connection.GetClient <TestPlanHttpClient>();

            // Get Test Suite
            TestSuite suite = testPlanClient.GetTestSuiteByIdAsync(projectName, 79, 83, SuiteExpand.Children).Result;

            Console.WriteLine("{0} {1}", suite.Id.ToString().PadLeft(6), suite.Name);

            return(suite);
        }
예제 #3
0
        /// <summary>
        /// Get test Suite Properties
        /// </summary>
        /// <param name="TeamProjectName"></param>
        /// <param name="PlanId"></param>
        /// <param name="TestSuiteId"></param>
        static void TestSuiteDetails(string TeamProjectName, int TestPlanId, int TestSuiteId, string ParentPath)
        {
            // SuiteExpand.Children does not work in 16.150.0-preview
            TestSuite testSuite = TestPlanClient.GetTestSuiteByIdAsync(TeamProjectName, TestPlanId, TestSuiteId, SuiteExpand.Children).Result;

            PrintSuiteInfo(testSuite, ParentPath);

            if (testSuite.HasChildren)
            {
                foreach (var suitedef in testSuite.Children)
                {
                    TestSuiteDetails(TeamProjectName, TestPlanId, suitedef.Id, ParentPath + "\\" + testSuite.Name);
                }
            }

            ViewTestCases(TeamProjectName, TestPlanId, testSuite);
        }
예제 #4
0
        public TestSuite GetTestSuiteById()
        {
            string projectName = ClientSampleHelpers.FindAnyProject(this.Context).Name;
            // Get a testplan client instance
            VssConnection      connection     = Context.Connection;
            TestPlanHttpClient testPlanClient = connection.GetClient <TestPlanHttpClient>();


            int       testPlanId = this._getTestPlanId();
            TestSuite newSuite;

            Context.TryGetValue <TestSuite>("$newSuite", out newSuite);
            int id = newSuite.Id;

            if (id != 0)
            {
                // Get Test Suite
                TestSuite suite = testPlanClient.GetTestSuiteByIdAsync(projectName, testPlanId, id, SuiteExpand.Children).Result;

                Context.Log("{0} {1}", suite.Id.ToString().PadLeft(6), suite.Name);
                return(suite);
            }
            return(null);
        }