Ejemplo n.º 1
0
 public static void CopySharedSteps(ITestCase slave, params ISharedStepReference[] ss)
 {
     foreach (var sharedStep in ss)
     {
         ISharedStepReference sharedStepReference = slave.CreateSharedStepReference();
         sharedStepReference.SharedStepId = sharedStep.SharedStepId;
         slave.Actions.Add(sharedStepReference);
     }
 }
Ejemplo n.º 2
0
        public static void AddE2ESteps(SharedStepsObject sharedStepsObject, int testCaseId)
        {
            TfsTeamProjectCollection tfs;

            tfs = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri(sharedStepsObject.uri));
            tfs.Authenticate();
            ITestManagementService     service     = (ITestManagementService)tfs.GetService(typeof(ITestManagementService));
            ITestManagementTeamProject testProject = service.GetTeamProject(sharedStepsObject.project);

            ITestCase testCase = testProject.TestCases.Find(testCaseId);

            foreach (string step in sharedStepsObject.actionSteps)
            {
                int sharedStepId = GetsharedStepId(step, sharedStepsObject);
                ISharedStepReference sharedStepReference = testCase.CreateSharedStepReference();
                sharedStepReference.SharedStepId = sharedStepId;
                testCase.Actions.Add(sharedStepReference);
            }
            testCase.Save();
        }
Ejemplo n.º 3
0
        public static void AddTestCaseSteps(SharedStepsObject sharedStepsObject, int testCaseId)
        {
            TfsTeamProjectCollection tfs;

            tfs = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri(sharedStepsObject.uri));
            tfs.Authenticate();
            ITestManagementService     service       = (ITestManagementService)tfs.GetService(typeof(ITestManagementService));
            ITestManagementTeamProject testProject   = service.GetTeamProject(sharedStepsObject.project);
            ITestCase            testCase            = testProject.TestCases.Find(testCaseId);
            ISharedStepReference sharedStepReference = testCase.CreateSharedStepReference();
            int sharedStepId = sharedStepsObject.id;

            sharedStepReference.SharedStepId = sharedStepId;
            testCase.Actions.Add(sharedStepReference);
            if (sharedStepsObject.automationValue.ToString() != "")
            {
                testCase.CustomFields["Automation Status1"].Value = sharedStepsObject.automationValue.ToString();                //"Planned";
            }

            testCase.Save();
        }
Ejemplo n.º 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();
            }
        }