コード例 #1
0
        /// <summary>
        /// Creates the new shared step.
        /// </summary>
        /// <param name="testCase">The test case.</param>
        /// <param name="sharedStepTitle">The shared step title.</param>
        /// <param name="stepTitle">The step title.</param>
        /// <param name="expectedResult">The expected result.</param>
        /// <returns>the shared step core object</returns>
        public static ISharedStep CreateNewSharedStep(TestCase testCase, string sharedStepTitle, string stepTitle, string expectedResult)
        {
            ISharedStepReference sharedStepReferenceCore = testCase.ITestCase.CreateSharedStepReference();
            ISharedStep sharedStepCore = ExecutionContext.TestManagementTeamProject.SharedSteps.Create();
            sharedStepReferenceCore.SharedStepId = sharedStepCore.Id;
            sharedStepCore.Title = sharedStepTitle;
            ITestStep testStepCore = sharedStepCore.CreateTestStep();
            testStepCore.ExpectedResult = expectedResult;
            testStepCore.Title = stepTitle;
            sharedStepCore.Actions.Add(testStepCore);

            return sharedStepCore;
        }
コード例 #2
0
 /// <summary>
 /// Adds the test steps to shared steps actions.
 /// </summary>
 /// <param name="sharedStepCore">The core shared step object.</param>
 /// <param name="sharedStepGuid">The shared step unique identifier.</param>
 /// <param name="selectedTestSteps">The test steps to add.</param>
 /// <param name="sharedStepTitle">The shared step title.</param>
 private static void AddTestStepsToSharedStep(ISharedStep sharedStepCore, Guid sharedStepGuid, List <TestStep> selectedTestSteps, string sharedStepTitle)
 {
     foreach (TestStep currentTestStep in selectedTestSteps)
     {
         ITestStep testStepCore = sharedStepCore.CreateTestStep();
         testStepCore.ExpectedResult = currentTestStep.ActionExpectedResult;
         testStepCore.Title          = currentTestStep.ActionTitle;
         sharedStepCore.Actions.Add(testStepCore);
         currentTestStep.TestStepGuid = sharedStepGuid;
         currentTestStep.Title        = sharedStepTitle;
         currentTestStep.IsShared     = true;
         currentTestStep.SharedStepId = sharedStepCore.Id;
     }
 }
コード例 #3
0
        public static int AddsharedSteps(SharedStepsObject sharedStepsObject, int newSharedStepId)
        {
            TfsTeamProjectCollection tfs;

            tfs = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri(sharedStepsObject.uri));             // https://mytfs.visualstudio.com/DefaultCollection
            tfs.Authenticate();
            ITestManagementService     service     = (ITestManagementService)tfs.GetService(typeof(ITestManagementService));
            ITestManagementTeamProject testProject = service.GetTeamProject(sharedStepsObject.project);
            ISharedStep sharedStep = testProject.SharedSteps.Find(newSharedStepId);

            for (int i = 0; i < sharedStepsObject.actionSteps.Count(); i++)
            {
                ITestStep newStep = sharedStep.CreateTestStep();
                newStep.Title          = sharedStepsObject.actionSteps[i];
                newStep.ExpectedResult = sharedStepsObject.results[i];
                sharedStep.Actions.Add(newStep);
            }
            sharedStep.Save();
            return(sharedStep.Id);
        }
コード例 #4
0
        public static void MyClassInitialize(TestContext testContext)
        {
            _testContext = testContext;

            AIT.TFS.SyncService.Service.AssemblyInit.Instance.Init();
            AIT.TFS.SyncService.Adapter.TFS2012.AssemblyInit.Instance.Init();

            var serverConfig = CommonConfiguration.TfsTestServerConfiguration(_testContext);

            CommonConfiguration.ReplaceConfigFileTokens(_testContext);
            var config = CommonConfiguration.GetSimpleFieldConfiguration("Requirement", Direction.OtherToTfs, FieldValueType.PlainText, "System.Title");

            _testAdapter = SyncServiceFactory.CreateTfsTestAdapter(serverConfig.TeamProjectCollectionUrl, serverConfig.TeamProjectName, config);
            var projectCollection = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri(serverConfig.TeamProjectCollectionUrl));

            _testManagement = projectCollection.GetService <ITestManagementService>().GetTeamProject(serverConfig.TeamProjectName);

            var sharedSteps = _testManagement.SharedSteps.Query("SELECT * FROM WorkItems WHERE System.Title='UnitTest_SharedStep'");

            _sharedStep = sharedSteps.FirstOrDefault();

            if (_sharedStep == null)
            {
                _sharedStep = _testManagement.SharedSteps.Create();
                var sharedStep1 = _sharedStep.CreateTestStep();
                sharedStep1.Title          = "First Shared Step";
                sharedStep1.ExpectedResult = "Result of first shared step";

                var sharedStep2 = _sharedStep.CreateTestStep();
                sharedStep2.Title          = "Second Shared Step .: @ParametersDontLikeSpecialChars";
                sharedStep2.ExpectedResult = "Result of second shared step";

                _sharedStep.Actions.Add(sharedStep1);
                _sharedStep.Actions.Add(sharedStep2);

                _sharedStep.Title = "UnitTest_SharedStep_1";
                _sharedStep.Save();
            }
            else
            {
                var sharedStep1 = _sharedStep.Actions[0] as ITestStep;
                if (sharedStep1 != null)
                {
                    sharedStep1.Title          = "First Shared Step";
                    sharedStep1.ExpectedResult = "Result of first shared step";
                }

                var sharedStep2 = _sharedStep.Actions[1] as ITestStep;
                if (sharedStep2 != null)
                {
                    sharedStep2.Title          = "Second Shared Step .: @ParametersDontLikeSpecialChars";
                    sharedStep2.ExpectedResult = "Result of second shared step";
                }

                _sharedStep.WorkItem.Open();
                _sharedStep.Save();
            }

            var testCases = _testManagement.TestCases.Query("SELECT * FROM WorkItems WHERE System.Title='UnitTest_TestCase'");

            _testCase = testCases.FirstOrDefault();

            if (_testCase == null)
            {
                _testCase       = _testManagement.TestCases.Create();
                _testCase.Title = "UnitTest_TestCase";

                var step1 = _testCase.CreateTestStep();
                step1.Title          = "First Step";
                step1.ExpectedResult = "Result of first step";

                var step2 = _testCase.CreateTestStep();
                step2.Title          = "Second Step";
                step2.ExpectedResult = "Result of second step";

                var step3 = _testCase.CreateTestStep();
                step3.Title          = "@DescriptionParameter";
                step3.ExpectedResult = "@ExpectedResultParameter";

                var ssr = _testCase.CreateSharedStepReference();
                ssr.SharedStepId = _sharedStep.Id;

                _testCase.Actions.Add(step1);
                _testCase.Actions.Add(step2);
                _testCase.Actions.Add(ssr);
                _testCase.Actions.Add(step3);
                _testCase.Save();
            }

            var testConfigurations = _testManagement.TestConfigurations.Query("Select * from TestConfiguration where Name='UnitTest_TestConfiguration'");

            _testConfiguration = testConfigurations.FirstOrDefault();

            if (_testConfiguration == null)
            {
                _testConfiguration      = _testManagement.TestConfigurations.Create();
                _testConfiguration.Name = "UnitTest_TestConfiguration";
                _testConfiguration.Save();
            }
        }
コード例 #5
0
 /// <summary>
 /// Adds the test steps to shared steps actions.
 /// </summary>
 /// <param name="sharedStepCore">The core shared step object.</param>
 /// <param name="sharedStepGuid">The shared step unique identifier.</param>
 /// <param name="selectedTestSteps">The test steps to add.</param>
 /// <param name="sharedStepTitle">The shared step title.</param>
 private static void AddTestStepsToSharedStep(ISharedStep sharedStepCore, Guid sharedStepGuid, List<TestStep> selectedTestSteps, string sharedStepTitle)
 {
     foreach (TestStep currentTestStep in selectedTestSteps)
     {
         ITestStep testStepCore = sharedStepCore.CreateTestStep();
         testStepCore.ExpectedResult = currentTestStep.ActionExpectedResult;
         testStepCore.Title = currentTestStep.ActionTitle;
         sharedStepCore.Actions.Add(testStepCore);
         currentTestStep.TestStepGuid = sharedStepGuid;
         currentTestStep.Title = sharedStepTitle;
         currentTestStep.IsShared = true;
         currentTestStep.SharedStepId = sharedStepCore.Id;
     }
 }