public TestPlanWebApi.TestPlan CreateTestPlan()
        {
            string projectName = ClientSampleHelpers.FindAnyProject(this.Context).Name;

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

            BuildDefinitionReference buildDefinition     = this._getBuildReference();
            TestOutcomeSettings      testOutcomeSettings = new TestOutcomeSettings()
            {
                SyncOutcomeAcrossSuites = true
            };
            ReleaseEnvironmentDefinitionReference releaseEnvironmentDefinition = this._getReleaseEnvironmentDefinitionReference();

            TestPlanWebApi.TestPlanCreateParams testPlanCreateParams = new TestPlanWebApi.TestPlanCreateParams()
            {
                Name            = "newCreatedPlan2",
                AreaPath        = this._getArea(),
                Iteration       = this._getIteration(),
                Description     = "description of the test plan",
                StartDate       = DateTime.Now.AddDays(2),
                EndDate         = DateTime.Now.AddDays(9),
                State           = "Inactive",
                BuildId         = this._getBuildId(),
                BuildDefinition = buildDefinition,
                ReleaseEnvironmentDefinition = releaseEnvironmentDefinition,
                TestOutcomeSettings          = testOutcomeSettings
            };


            // create a test plan
            TestPlanWebApi.TestPlan plan = testPlanClient.CreateTestPlanAsync(testPlanCreateParams, projectName).Result;


            Context.SetValue <TestPlanWebApi.TestPlan>("$newPlan2", plan);
            Context.Log("{0} {1}", plan.Id, plan.Name);
            return(plan);
        }
Example #2
0
        /// <summary>
        /// Create a new test plan
        /// </summary>
        /// <param name="TeamProjectName"></param>
        /// <param name="TestPlanName"></param>
        /// <param name="StartDate"></param>
        /// <param name="FinishDate"></param>
        /// <param name="AreaPath"></param>
        /// <param name="IterationPath"></param>
        /// <returns></returns>
        static int CreateTestPlan(string TeamProjectName, string TestPlanName, DateTime?StartDate = null, DateTime?FinishDate = null, string AreaPath = "", string IterationPath = "")
        {
            if (IterationPath != "")
            {
                IterationPath = TeamProjectName + "\\" + IterationPath;
            }
            if (AreaPath != "")
            {
                AreaPath = TeamProjectName + "\\" + AreaPath;
            }

            TestPlanCreateParams newPlanDef = new TestPlanCreateParams()
            {
                Name      = TestPlanName,
                StartDate = StartDate,
                EndDate   = FinishDate,
                AreaPath  = AreaPath,
                Iteration = IterationPath
            };

            return(TestPlanClient.CreateTestPlanAsync(newPlanDef, TeamProjectName).Result.Id);
        }
        public TestPlanWebApi.TestPlan CreateTestPlanWithAreaPathAndIteration()
        {
            string projectName = ClientSampleHelpers.FindAnyProject(this.Context).Name;

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

            TestPlanWebApi.TestPlanCreateParams testPlanCreateParams = new TestPlanWebApi.TestPlanCreateParams()
            {
                Name      = "newCreatedPlan1",
                AreaPath  = this._getArea(),
                Iteration = this._getIteration()
            };


            // create a test plan
            TestPlanWebApi.TestPlan plan = testPlanClient.CreateTestPlanAsync(testPlanCreateParams, projectName).Result;


            Context.SetValue <TestPlanWebApi.TestPlan>("$newPlan1", plan);
            Context.Log("{0} {1}", plan.Id, plan.Name);
            return(plan);
        }