예제 #1
0
        /// <summary>
        /// Create a new test suite
        /// </summary>
        /// <param name="TeamProjectName"></param>
        /// <param name="TestPlanId"></param>
        /// <param name="TestSuiteName"></param>
        /// <param name="TestSuiteType"></param>
        /// <param name="ParentPath"></param>
        /// <param name="SuiteQuery"></param>
        /// <param name="RequirementIds"></param>
        /// <returns></returns>
        static bool CreateTestSuite(string TeamProjectName, int TestPlanId, string TestSuiteName = "", TestSuiteType SuiteType = TestSuiteType.StaticTestSuite, string ParentPath = "", string SuiteQuery = "", int RequirementId = 0)
        {
            switch (SuiteType)
            {
            case TestSuiteType.StaticTestSuite:
                if (TestSuiteName == "")
                {
                    Console.WriteLine("Set the name for the test suite"); return(false);
                }
                break;

            case TestSuiteType.DynamicTestSuite:
                if (TestSuiteName == "")
                {
                    Console.WriteLine("Set the name for the test suite"); return(false);
                }
                if (SuiteQuery == "")
                {
                    Console.WriteLine("Set the query for the new a suite"); return(false);
                }
                break;

            case TestSuiteType.RequirementTestSuite:
                if (RequirementId == 0)
                {
                    Console.WriteLine("Set the requrement id for the test suite"); return(false);
                }
                break;
            }

            int parentsuiteId = GetSuiteId(TeamProjectName, TestPlanId, ParentPath);

            if (parentsuiteId > 0)
            {
                TestSuiteCreateParams newSuite = new TestSuiteCreateParams()
                {
                    Name          = TestSuiteName,
                    SuiteType     = SuiteType,
                    QueryString   = SuiteQuery,
                    RequirementId = RequirementId,
                    ParentSuite   = new TestSuiteReference()
                    {
                        Id = parentsuiteId
                    }
                };

                TestSuite testSuite = TestPlanClient.CreateTestSuiteAsync(newSuite, TeamProjectName, TestPlanId).Result;
                Console.WriteLine("The Test Suite has been created: " + testSuite.Id + " - " + testSuite.Name);
            }
            else
            {
                Console.WriteLine("Can not find the parent test suite"); return(false);
            }

            return(true);
        }
예제 #2
0
        public TestSuite CreateTestSuite()
        {
            string projectName = ClientSampleHelpers.FindAnyProject(this.Context).Name;
            int    testPlanId  = this._getTestPlanId();

            // Get a testplan client instance
            VssConnection      connection     = Context.Connection;
            TestPlanHttpClient testPlanClient = connection.GetClient <TestPlanHttpClient>();

            int parentSuiteId = this._getRootSuiteId();
            TestSuiteCreateParams testSuiteCreateParams = new TestSuiteCreateParams()
            {
                Name        = "SubSuite 1.1.1",
                SuiteType   = TestSuiteType.StaticTestSuite,
                ParentSuite = new TestSuiteReference()
                {
                    Id = parentSuiteId
                },
                InheritDefaultConfigurations = false,
                DefaultConfigurations        = new List <TestConfigurationReference>()
                {
                    new TestConfigurationReference()
                    {
                        Id = 1
                    },
                    new TestConfigurationReference()
                    {
                        Id = 2
                    }
                }
            };

            // Create Test Suite
            TestSuite suite = testPlanClient.CreateTestSuiteAsync(testSuiteCreateParams, projectName, testPlanId).Result;

            Context.SetValue <TestSuite>("$newSuite", suite);
            Context.Log("{0} {1}", suite.Id.ToString().PadLeft(6), suite.Name);
            return(suite);
        }