Ejemplo n.º 1
0
        public void MyTestInitialize()
        {
            var config = CommonConfiguration.GetSimpleFieldConfiguration("Requirement", Direction.OtherToTfs, FieldValueType.PlainText, "System.Title");
            var serverConfiguration = CommonConfiguration.TfsTestServerConfiguration(_testContext);

            _testAdapter = SyncServiceFactory.CreateTfsTestAdapter(serverConfiguration.TeamProjectCollectionUrl, serverConfiguration.TeamProjectName, config);
        }
Ejemplo n.º 2
0
        public static void ClassInitialize(TestContext testContext)
        {
            AIT.TFS.SyncService.Service.AssemblyInit.Instance.Init();
            AIT.TFS.SyncService.Adapter.TFS2012.AssemblyInit.Instance.Init();
            var projectCollection = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(CommonConfiguration.Tfs2013ServerConfiguration(testContext).ServerName, true, false);

            testManagement = projectCollection.GetService <ITestManagementService>().GetTeamProject(CommonConfiguration.Tfs2013ServerConfiguration(testContext).ProjectName);
            var config = CommonConfiguration.GetSimpleFieldConfiguration("Requirement", Direction.OtherToTfs, FieldValueType.PlainText, "System.Title");

            testAdapter = SyncServiceFactory.CreateTfsTestAdapter(CommonConfiguration.Tfs2013ServerConfiguration(testContext).ServerName, CommonConfiguration.Tfs2013ServerConfiguration(testContext).ProjectName, config);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// This method creates a word document with the TestResultReport-Command
        /// </summary>
        public void CreateTestResultDocument(DocumentConfiguration documentConfiguration)
        {
            try
            {
                SyncServiceTrace.D(Resources.CreateTestResultDoc);
                _documentConfiguration = documentConfiguration;
                Initialize();
                var testResultSettings = _documentConfiguration.TestResultSettings;
                var testAdapter        = SyncServiceFactory.CreateTfsTestAdapter(_documentModel.TfsServer, _documentModel.TfsProject, _documentModel.Configuration);
                TestCaseSortType testCaseSortType;
                Enum.TryParse(testResultSettings.SortTestCasesBy, out testCaseSortType);
                DocumentStructureType documentStructure;
                Enum.TryParse(testResultSettings.DocumentStructure, out documentStructure);
                ConfigurationPositionType configurationPositionType;
                Enum.TryParse(testResultSettings.TestConfigurationsPosition, out configurationPositionType);
                var testPlan = testAdapter.GetTestPlans(null).Where(plan => plan.Name == testResultSettings.TestPlan).FirstOrDefault();
                if (testPlan == null)
                {
                    SyncServiceTrace.D(Resources.TestSettingsInvalidTestPlan);
                    throw new ArgumentException(Resources.TestSettingsInvalidTestPlan);
                }
                var testSuiteSearcher = new TestSuiteSearcher(testPlan);
                var testSuite         = testSuiteSearcher.SearchTestSuiteWithinTestPlan(testResultSettings.TestSuite);

                var reportModel = new TestResultReportModel(_documentModel,
                                                            testAdapter,
                                                            testPlan,
                                                            testSuite,
                                                            testResultSettings.CreateDocumentStructure,
                                                            testResultSettings.SkipLevels,
                                                            documentStructure,
                                                            testCaseSortType,
                                                            testResultSettings.IncludeTestConfigurations,
                                                            configurationPositionType,
                                                            testResultSettings.IncludeOnlyMostRecentResults,
                                                            testResultSettings.MostRecentForAllConfigurations,
                                                            testResultSettings.Build,
                                                            testResultSettings.TestConfiguration,
                                                            new TestReportingProgressCancellationService(false));

                reportModel.CreateReport();
                FinalizeDocument();
            }
            catch
            {
                if (_wordApplication != null)
                {
                    _wordApplication.Quit();
                }
                // ReSharper disable once PossibleIntendedRethrow
                throw;
            }
        }
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();
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Background method to import the work items from TFS.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">A <see cref="RunWorkerCompletedEventArgs"/> that contains the event data</param>
        private void DoImport(object sender, DoWorkEventArgs e)
        {
            SyncServiceTrace.I(Resources.ImportWorkItems);

            if (_workItemSyncService == null || _configService == null)
            {
                SyncServiceTrace.D(Resources.ServicesNotExists);
                throw new Exception(Resources.ServicesNotExists);
            }

            _documentModel.Save();

            _destination.ProcessOperations(_configuration.PreOperations);
            var importWorkItems = (from wim in FoundWorkItems

                                   select wim.Item).ToList();

            SyncServiceTrace.D(Resources.NumberOfFoundWorkItems + FoundWorkItems.Count);

            // display progress dialog
            var progressService = SyncServiceFactory.GetService <IProgressService>();

            progressService.ShowProgress();
            progressService.NewProgress(Resources.GetWorkItems_Title);

            // search for already existing work items in word and ask whether to overide them
            if (!(_source.Open(importWorkItems.Select(x => x.TfsItem.Id).ToArray()) && _destination.Open(null)))
            {
                return;
            }
            if (importWorkItems.Select(x => x.TfsItem.Id).Intersect(_destination.WorkItems.Select(x => x.Id)).Any())
            {
            }
            if (!_testSpecByQuery)
            {
                _workItemSyncService.Refresh(_source, _destination, importWorkItems.Select(x => x.TfsItem), _configuration);
            }

            if (_testSpecByQuery)
            {
                var testAdapter       = SyncServiceFactory.CreateTfsTestAdapter(_documentModel.TfsServer, _documentModel.TfsProject, _documentModel.Configuration);
                var model             = new TestSpecificationReportByQueryModel(_tfsService, _documentModel, testAdapter, _workItems);
                var expandSharedsteps = _configuration.ConfigurationTest.ExpandSharedSteps;
                var testCases         = model.GetTestCasesFromWorkItems(importWorkItems, expandSharedsteps);
                var sharedSteps       = model.GetSharedStepsFromWorkItems(importWorkItems);
                // Get any pre and post operations for the reports
                var preOperations    = _configuration.ConfigurationTest.GetPreOperationsForTestSpecification();
                var postOperations   = _configuration.ConfigurationTest.GetPostOperationsForTestSpecification();
                var testReport       = SyncServiceFactory.CreateWord2007TestReportAdapter(_wordDocument, _configuration);
                var testReportHelper = new TestReportHelper(testAdapter, testReport, _configuration, () => !IsImporting);

                testReportHelper.ProcessOperations(preOperations);
                if (sharedSteps.Count > 0)
                {
                    _workItemSyncService.RefreshAndSubstituteSharedStepItems(_source, _destination, importWorkItems.Select(x => x.TfsItem), _configuration, testReportHelper, sharedSteps);
                }
                if (testCases.Count > 0)
                {
                    _workItemSyncService.RefreshAndSubstituteTestItems(_source, _destination, importWorkItems.Select(x => x.TfsItem), _configuration, testReportHelper, testCases);
                }
                if (_testReportingProgressCancellationService.CheckIfContinue())
                {
                    testReportHelper.CreateSummaryPage(_wordDocument, null);
                    testReportHelper.ProcessOperations(postOperations);
                }
                else
                {
                    SyncServiceTrace.I(Resources.DoImportError);
                }

                _documentModel.TestReportGenerated = true;
            }

            _destination.ProcessOperations(_configuration.PostOperations);
        }