Пример #1
0
        /// <summary>
        /// The method generates report by test plan structure.
        /// </summary>
        /// <param name="testSuite"><see cref="ITfsTestSuite"/> is the source of test cases to write out.</param>
        private void CreateReportByTestPlanHierarchy(ITfsTestSuite testSuite)
        {
            SyncServiceTrace.D("Creating report by test plan hierarchy...");
            if (testSuite == null)
            {
                SyncServiceTrace.D("Test suite is null");
                return;
            }
            // Get the necessary objects.
            var config     = SyncServiceFactory.GetService <IConfigurationService>().GetConfiguration(Document);
            var testReport = SyncServiceFactory.CreateWord2007TestReportAdapter(Document, config);
            // Get the detailed test plan.
            var testPlanDetail = TestAdapter.GetTestPlanDetail(testSuite);

            if (testPlanDetail == null)
            {
                return;
            }

            // Create report helper
            var testReportHelper = new TestReportHelper(TestAdapter, testReport, config, CancellationPending);
            // Insert test plan template
            var templateName = config.ConfigurationTest.ConfigurationTestSpecification.TestPlanTemplate;

            testReportHelper.InsertTestPlanTemplate(templateName, testPlanDetail);

            // Common part
            if (IncludeTestConfigurations && SelectedConfigurationPositionType == Contracts.Enums.Model.ConfigurationPositionType.BeneathTestPlan)
            {
                CreateConfigurationPart();
            }

            // Call recursion
            CreateReportByTestSuiteHierarchy(testSuite, 1, true);
        }
        async void DoWorkAsync(object state)
        {
            var tesReportGeneratorFactory = new TestReportGeneratorFactory(this.storage);

            ITestResultReport[] testResultReports = await TestReportHelper.GenerateTestResultReportsAsync(Settings.Current.TrackingId, Settings.Current.GetReportMetadataList(), tesReportGeneratorFactory, this.logger);

            if (testResultReports.Length == 0)
            {
                this.logger.LogInformation("No test result report is generated.");
                return;
            }

            var    testSummary    = new TestSummary(testResultReports);
            string reportsContent = JsonConvert.SerializeObject(testSummary, Formatting.Indented);

            this.logger.LogInformation($"Test result report{Environment.NewLine}{reportsContent}");

            await AzureLogAnalytics.Instance.PostAsync(
                Settings.Current.LogAnalyticsWorkspaceId,
                Settings.Current.LogAnalyticsSharedKey,
                reportsContent,
                Settings.Current.LogAnalyticsLogType);

            this.logger.LogInformation("Successfully send reports to LogAnalytics");
        }
Пример #3
0
        public void TestReportHelper_EvaluateObjectQueriesWithWorkItemName_ShouldInnovacateAddCustomMethod()
        {
            // setup
            var tfsTestAdapter  = new Mock <ITfsTestAdapter>();
            var wordTestAdapter = new Mock <IWord2007TestReportAdapter>();

            wordTestAdapter.SetupAllProperties();
            var testResultDetail = new Mock <ITfsTestResultDetail>();

            var destElement = new Mock <IElement>();

            destElement.SetupGet(x => x.ItemName).Returns("Change Request");

            var objectQuery = new Mock <IObjectQuery>();

            objectQuery.SetupGet(x => x.DestinationElements).Returns(new List <IElement> {
                destElement.Object
            });
            objectQuery.SetupGet(x => x.Name).Returns("TestObjectQuery");

            var replacement = new Mock <IConfigurationTestReplacement>();

            replacement.SetupGet(x => x.PropertyToEvaluate).Returns("TestObjectQuery");
            replacement.SetupGet(x => x.Bookmark).Returns("Bookmark");

            var configuration = new Mock <IConfiguration> {
                DefaultValue = DefaultValue.Mock
            };

            configuration.Setup(x => x.ObjectQueries).Returns(new List <IObjectQuery> {
                objectQuery.Object
            });

            configuration.Setup(x => x.ConfigurationTest.GetReplacements(It.IsAny <string>())).Returns(new List <IConfigurationTestReplacement> {
                replacement.Object
            });
            configuration.SetupGet(x => x.ConfigurationTest.SetHyperlinkBase).Returns(true);
            configuration.SetupGet(x => x.ConfigurationTest.ShowHyperlinkBaseMessageBoxes).Returns(false);


            testResultDetail.Setup(x => x.GetCustomObject("Name")).Returns("name");
            testResultDetail.Setup(x => x.GetCustomObject("Name")).Returns(() => null);


            // test
            var helper = new TestReportHelper(tfsTestAdapter.Object, wordTestAdapter.Object, configuration.Object, () => false);

            helper.InsertTestResult("test", testResultDetail.Object);

            // verify that the AddCustomObject method was innovated
            testResultDetail.Verify();
            testResultDetail.Verify(x => x.AddCustomObjects("TestObjectQuery", It.IsAny <object>()));
        }
Пример #4
0
        /// <summary>
        /// Process an Operation
        /// </summary>
        private void ProcessPostOperations()
        {
            //Process Pre Operations
            // Get the necessary objects.
            var config = SyncServiceFactory.GetService <IConfigurationService>().GetConfiguration(Document);
            // Create Report helper
            var operation        = config.ConfigurationTest.GetPostOperationsForTestSpecification();
            var testReportHelper = new TestReportHelper(TestAdapter, testReportOperation, config, CancellationPending);

            testReportHelper.ProcessOperations(operation);
            testReportOperation.UndoPreparationsDocumentForLongTermOperation();
        }
Пример #5
0
        public void TestReportHelper_EvaluateAttachmentLink_WithoutGuid_ShouldDownloadAndReplaceBookmarkWithPropertyValueAndHyperlink()
        {
            // setup
            var folder    = Path.GetTempPath();
            var localPath = string.Empty;

            var tfsTestAdapter  = new Mock <ITfsTestAdapter>();
            var wordTestAdapter = new Mock <IWord2007TestReportAdapter>();

            wordTestAdapter.SetupGet(x => x.DocumentPath).Returns(folder);
            wordTestAdapter.SetupGet(x => x.AttachmentFolder).Returns("Attachments");

            // ReSharper disable once ImplicitlyCapturedClosure
            wordTestAdapter.Setup(x => x.ReplaceBookmarkHyperlink(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>())).Callback((string x, string y, string z) => localPath = z);

            var attachment = new Mock <ITestAttachment>();

            attachment.SetupGet(f => f.Length).Returns(1);
            attachment.SetupGet(f => f.IsComplete).Returns(true);

            var testResultDetail = new Mock <ITfsTestResultDetail>();

            testResultDetail.SetupGet(x => x.AssociatedObject).Returns(attachment.Object);
            testResultDetail.Setup(x => x.PropertyValue("Name", It.IsAny <Func <IEnumerable, IEnumerable> >())).Returns("MyAttachmentName");
            testResultDetail.Setup(x => x.PropertyValue("Comment", It.IsAny <Func <IEnumerable, IEnumerable> >())).Returns("MyComment");

            var replacement = new Mock <IConfigurationTestReplacement>();

            replacement.SetupGet(x => x.PropertyToEvaluate).Returns("Comment");
            replacement.SetupGet(x => x.Bookmark).Returns("Bookmark");
            replacement.SetupGet(x => x.AttachmentLink.Mode).Returns(AttachmentLinkMode.DownloadAndLinkToLocalFile);

            var configuration = new Mock <IConfiguration> {
                DefaultValue = DefaultValue.Mock
            };

            configuration.Setup(x => x.ConfigurationTest.GetReplacements(It.IsAny <string>())).Returns(new List <IConfigurationTestReplacement> {
                replacement.Object
            });
            configuration.SetupGet(e => e.AttachmentFolderMode).Returns(AttachmentFolderMode.WithoutGuid);

            // test
            var helper = new TestReportHelper(tfsTestAdapter.Object, wordTestAdapter.Object, configuration.Object, () => false);

            helper.InsertTestResult("test", testResultDetail.Object);

            // verify
            Assert.IsTrue(localPath.EndsWith("MyAttachmentName", StringComparison.OrdinalIgnoreCase));
            attachment.Verify(x => x.DownloadToFile(folder + localPath), Times.Once());
            wordTestAdapter.Verify(x => x.ReplaceBookmarkHyperlink("Bookmark", "MyComment", It.IsAny <string>()), Times.Once());
            wordTestAdapter.VerifySet(x => x.HyperlinkBase = It.IsAny <string>(), Times.Never());
        }
Пример #6
0
        public void TestReportHelper_EvaluateAttachmentLink_ShouldDownloadAndReplaceBookmarkWithPropertyValueWithoutHyperlink()
        {
            // setup
            var folder = Path.GetTempPath();
            // ReSharper disable once NotAccessedVariable
            var localPath = string.Empty;

            var tfsTestAdapter  = new Mock <ITfsTestAdapter>();
            var wordTestAdapter = new Mock <IWord2007TestReportAdapter>();

            wordTestAdapter.SetupGet(x => x.DocumentPath).Returns(folder);
            wordTestAdapter.SetupGet(x => x.AttachmentFolder).Returns("Attachments");

            var attachment = new Mock <ITestAttachment>();

            attachment.SetupGet(f => f.Length).Returns(1);
            attachment.SetupGet(f => f.IsComplete).Returns(true);

            var testResultDetail = new Mock <ITfsTestResultDetail>();

            testResultDetail.SetupGet(x => x.AssociatedObject).Returns(attachment.Object);
            testResultDetail.Setup(x => x.PropertyValue("Name", It.IsAny <Func <IEnumerable, IEnumerable> >())).Returns("MyAttachmentName");
            testResultDetail.Setup(x => x.PropertyValue("Comment", It.IsAny <Func <IEnumerable, IEnumerable> >())).Returns("MyComment");
            attachment.Setup(x => x.DownloadToFile(It.IsAny <string>())).Callback((string x) => localPath = x);


            var replacement = new Mock <IConfigurationTestReplacement>();

            replacement.SetupGet(x => x.PropertyToEvaluate).Returns("Comment");
            replacement.SetupGet(x => x.Bookmark).Returns("Bookmark");
            replacement.SetupGet(x => x.AttachmentLink.Mode).Returns(AttachmentLinkMode.DownloadOnly);

            var configuration = new Mock <IConfiguration> {
                DefaultValue = DefaultValue.Mock
            };

            configuration.Setup(x => x.ConfigurationTest.GetReplacements(It.IsAny <string>())).Returns(new List <IConfigurationTestReplacement> {
                replacement.Object
            });

            // test
            var helper = new TestReportHelper(tfsTestAdapter.Object, wordTestAdapter.Object, configuration.Object, () => false);

            helper.InsertTestResult("test", testResultDetail.Object);

            // verify
            attachment.Verify(x => x.DownloadToFile(It.IsRegex(folder.Replace("\\", "\\\\") + ".*" + "MyAttachmentName")), Times.Once());
            wordTestAdapter.Verify(x => x.ReplaceBookmarkText("Bookmark", "MyComment", PropertyValueFormat.PlainText, null), Times.Once());
            wordTestAdapter.Verify(x => x.ReplaceBookmarkHyperlink(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>()), Times.Never());
            wordTestAdapter.VerifySet(x => x.HyperlinkBase = It.IsAny <string>(), Times.Never());
        }
Пример #7
0
        public async Task TestGenerateTestResultReportsAsync_MissingTrackingId()
        {
            var mockLogger = new Mock <ILogger>();
            var mockTestReportGeneratorFactory = new Mock <ITestReportGeneratorFactory>();

            ArgumentException ex = await Assert.ThrowsAsync <ArgumentException>(() =>
                                                                                TestReportHelper.GenerateTestResultReportsAsync(
                                                                                    string.Empty,
                                                                                    new List <ITestReportMetadata>(),
                                                                                    mockTestReportGeneratorFactory.Object,
                                                                                    mockLogger.Object));

            Assert.StartsWith("trackingId", ex.Message, StringComparison.Ordinal);
        }
Пример #8
0
        public async Task<ContentResult> GetReportsAsync()
        {
            ITestResultReport[] testResultReports = await TestReportHelper.GenerateTestResultReports(this.storage, Logger);

            if (testResultReports.Length == 0)
            {
                return new ContentResult { Content = "No test report generated" };
            }

            return new ContentResult
            {
                Content = this.AddManualRunReportingHeading(JsonConvert.SerializeObject(testResultReports, Formatting.Indented)) // explicit serialization needed due to the wrapping list
            };
        }
Пример #9
0
        public void TestReportHelper_EvaluateAttachmentLink_ShouldLinkToServer()
        {
            // setup
            //var folder = Path.GetTempPath();
            //var link = string.Empty;

            var tfsTestAdapter  = new Mock <ITfsTestAdapter>();
            var wordTestAdapter = new Mock <IWord2007TestReportAdapter>();

            wordTestAdapter.SetupGet(x => x.DocumentPath).Returns("MyFolder");
            wordTestAdapter.SetupGet(x => x.AttachmentFolder).Returns("Attachments");
            //wordTestAdapter.Setup(x => x.ReplaceBookmarkHyperlink(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>())).Callback((string x, string y, string z) => link = z);

            var attachment = new Mock <ITestAttachment>();

            attachment.SetupGet(f => f.Length).Returns(1);
            attachment.SetupGet(f => f.IsComplete).Returns(true);
            attachment.Setup(x => x.Uri).Returns(new Uri("http://wwww.test.de"));
            var testResultDetail = new Mock <ITfsTestResultDetail>();

            testResultDetail.SetupGet(x => x.AssociatedObject).Returns(attachment.Object);
            testResultDetail.Setup(x => x.PropertyValue("Name", It.IsAny <Func <IEnumerable, IEnumerable> >())).Returns("MyAttachmentName");
            testResultDetail.Setup(x => x.PropertyValue("Comment", It.IsAny <Func <IEnumerable, IEnumerable> >())).Returns("MyComment");

            var replacement = new Mock <IConfigurationTestReplacement>();

            replacement.SetupGet(x => x.PropertyToEvaluate).Returns("Comment");
            replacement.SetupGet(x => x.Bookmark).Returns("Bookmark");
            replacement.SetupGet(x => x.AttachmentLink.Mode).Returns(AttachmentLinkMode.LinkToServerVersion);

            var configuration = new Mock <IConfiguration> {
                DefaultValue = DefaultValue.Mock
            };

            configuration.Setup(x => x.ConfigurationTest.GetReplacements(It.IsAny <string>())).Returns(new List <IConfigurationTestReplacement> {
                replacement.Object
            });

            // test
            var helper = new TestReportHelper(tfsTestAdapter.Object, wordTestAdapter.Object, configuration.Object, () => false);

            helper.InsertTestResult("test", testResultDetail.Object);

            // verify
            attachment.Verify(x => x.DownloadToFile(It.IsAny <string>()), Times.Never());
            wordTestAdapter.Verify(x => x.ReplaceBookmarkHyperlink("Bookmark", "MyComment", (new Uri("http://wwww.test.de").ToString())), Times.Once());
            wordTestAdapter.VerifySet(x => x.HyperlinkBase = It.IsAny <string>(), Times.Never());
        }
Пример #10
0
        public void TestReportHelper_EvaluateAttachmentLink_ShouldSimulateLocalFileNameProperty()
        {
            // setup
            var folder    = Path.GetTempPath();
            var localPath = string.Empty;

            var tfsTestAdapter  = new Mock <ITfsTestAdapter>();
            var wordTestAdapter = new Mock <IWord2007TestReportAdapter>();

            wordTestAdapter.SetupGet(x => x.DocumentPath).Returns(folder);
            wordTestAdapter.SetupGet(x => x.AttachmentFolder).Returns("Attachments");
            wordTestAdapter.Setup(x => x.ReplaceBookmarkHyperlink(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>())).Callback((string x, string y, string z) => localPath = z);

            var attachment = new Mock <ITestAttachment>();

            attachment.SetupGet(f => f.Length).Returns(1);
            attachment.SetupGet(f => f.IsComplete).Returns(true);
            var testResultDetail = new Mock <ITfsTestResultDetail>();

            testResultDetail.SetupGet(x => x.AssociatedObject).Returns(attachment.Object);
            testResultDetail.Setup(x => x.PropertyValue("Name", It.IsAny <Func <IEnumerable, IEnumerable> >())).Returns("MyAttachmentName");
            testResultDetail.Setup(x => x.PropertyValue("LocalPath", It.IsAny <Func <IEnumerable, IEnumerable> >())).Returns("ThisShouldNotBeReturnedAsThisPropertyIsFake");

            var replacement = new Mock <IConfigurationTestReplacement>();

            replacement.SetupGet(x => x.PropertyToEvaluate).Returns("LocalFilename");
            replacement.SetupGet(x => x.Bookmark).Returns("Bookmark");
            replacement.SetupGet(x => x.AttachmentLink.Mode).Returns(AttachmentLinkMode.DownloadAndLinkToLocalFile);

            var configuration = new Mock <IConfiguration> {
                DefaultValue = DefaultValue.Mock
            };

            configuration.Setup(x => x.ConfigurationTest.GetReplacements(It.IsAny <string>())).Returns(new List <IConfigurationTestReplacement> {
                replacement.Object
            });

            // test
            var helper = new TestReportHelper(tfsTestAdapter.Object, wordTestAdapter.Object, configuration.Object, () => false);

            helper.InsertTestResult("test", testResultDetail.Object);

            // verify
            var localFilename = localPath.Replace(wordTestAdapter.Object.AttachmentFolder + Path.DirectorySeparatorChar, "");

            wordTestAdapter.Verify(x => x.ReplaceBookmarkHyperlink("Bookmark", localFilename, localPath), Times.Once());
        }
Пример #11
0
        public void TestReportHelper_EvaluateAttachmentLink_ShouldSetHyperlinkBase()
        {
            // setup
            var folder = Path.GetTempPath();

            var tfsTestAdapter  = new Mock <ITfsTestAdapter>();
            var wordTestAdapter = new Mock <IWord2007TestReportAdapter>();

            wordTestAdapter.SetupAllProperties();
            wordTestAdapter.SetupGet(x => x.DocumentPath).Returns(folder);
            wordTestAdapter.SetupGet(x => x.AttachmentFolder).Returns("Attachments");

            var attachment = new Mock <ITestAttachment>();

            attachment.SetupGet(f => f.Length).Returns(1);
            attachment.SetupGet(f => f.IsComplete).Returns(true);
            var testResultDetail = new Mock <ITfsTestResultDetail>();

            testResultDetail.SetupGet(x => x.AssociatedObject).Returns(attachment.Object);
            testResultDetail.Setup(x => x.PropertyValue("Name", It.IsAny <Func <IEnumerable, IEnumerable> >())).Returns("MyAttachmentName");
            testResultDetail.Setup(x => x.PropertyValue("LocalPath", It.IsAny <Func <IEnumerable, IEnumerable> >())).Returns("ThisShouldNotBeReturnedAsThisPropertyIsFake");

            var replacement = new Mock <IConfigurationTestReplacement>();

            replacement.SetupGet(x => x.PropertyToEvaluate).Returns("LocalPath");
            replacement.SetupGet(x => x.Bookmark).Returns("Bookmark");
            replacement.SetupGet(x => x.AttachmentLink.Mode).Returns(AttachmentLinkMode.DownloadAndLinkToLocalFile);

            var configuration = new Mock <IConfiguration> {
                DefaultValue = DefaultValue.Mock
            };

            configuration.Setup(x => x.ConfigurationTest.GetReplacements(It.IsAny <string>())).Returns(new List <IConfigurationTestReplacement> {
                replacement.Object
            });
            configuration.SetupGet(x => x.ConfigurationTest.SetHyperlinkBase).Returns(true);
            configuration.SetupGet(x => x.ConfigurationTest.ShowHyperlinkBaseMessageBoxes).Returns(false);

            // test
            var helper = new TestReportHelper(tfsTestAdapter.Object, wordTestAdapter.Object, configuration.Object, () => false);

            helper.InsertTestResult("test", testResultDetail.Object);

            // verify
            wordTestAdapter.VerifySet(x => x.HyperlinkBase = folder);
        }
Пример #12
0
        public void TestReportHelper_EvaluateAttachmentLink_IncompleteAttachmentWithLength0_ShouldFail()
        {
            // setup
            var folder = Path.GetTempPath();
            // ReSharper disable once NotAccessedVariable
            var localPath = string.Empty;

            var tfsTestAdapter  = new Mock <ITfsTestAdapter>();
            var wordTestAdapter = new Mock <IWord2007TestReportAdapter>();

            wordTestAdapter.SetupGet(x => x.DocumentPath).Returns(folder);
            wordTestAdapter.SetupGet(x => x.AttachmentFolder).Returns("Attachments");

            wordTestAdapter.Setup(x => x.ReplaceBookmarkHyperlink(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>())).Callback((string x, string y, string z) => localPath = z);

            var attachment = new Mock <ITestAttachment>();

            attachment.SetupGet(f => f.Length).Returns(0);
            attachment.SetupGet(f => f.IsComplete).Returns(false);

            var testResultDetail = new Mock <ITfsTestResultDetail>();

            testResultDetail.SetupGet(x => x.AssociatedObject).Returns(attachment.Object);
            testResultDetail.Setup(x => x.PropertyValue("Name", It.IsAny <Func <IEnumerable, IEnumerable> >())).Returns("MyAttachmentName");
            testResultDetail.Setup(x => x.PropertyValue("Comment", It.IsAny <Func <IEnumerable, IEnumerable> >())).Returns("MyComment");

            var replacement = new Mock <IConfigurationTestReplacement>();

            replacement.SetupGet(x => x.PropertyToEvaluate).Returns("Comment");
            replacement.SetupGet(x => x.Bookmark).Returns("Bookmark");
            replacement.SetupGet(x => x.AttachmentLink.Mode).Returns(AttachmentLinkMode.DownloadAndLinkToLocalFile);

            var configuration = new Mock <IConfiguration> {
                DefaultValue = DefaultValue.Mock
            };

            configuration.Setup(x => x.ConfigurationTest.GetReplacements(It.IsAny <string>())).Returns(new List <IConfigurationTestReplacement> {
                replacement.Object
            });
            configuration.SetupGet(e => e.AttachmentFolderMode).Returns(AttachmentFolderMode.WithoutGuid);

            // test
            var helper = new TestReportHelper(tfsTestAdapter.Object, wordTestAdapter.Object, configuration.Object, () => false);

            helper.InsertTestResult("test", testResultDetail.Object);
        }
Пример #13
0
        public async Task <ContentResult> GetReportsAsync()
        {
            var testReportGeneratorFactory = new TestReportGeneratorFactory(this.storage);

            ITestResultReport[] testResultReports = await TestReportHelper.GenerateTestResultReportsAsync(Settings.Current.TrackingId, Settings.Current.GetReportMetadataList(), testReportGeneratorFactory, Logger);

            if (testResultReports.Length == 0)
            {
                return(new ContentResult {
                    Content = "No test report generated"
                });
            }

            return(new ContentResult
            {
                Content = this.AddManualRunReportingHeading(JsonConvert.SerializeObject(testResultReports, Formatting.Indented)) // explicit serialization needed due to the wrapping list
            });
        }
Пример #14
0
        private static void ExecuteObjectQuery(bool includeOnlyMostRecentTestResults, bool includeOnlyMostRecentTestResultForAllConfigurations)
        {
            var destElement = new Mock <IElement>();
            var objectQuery = new Mock <IObjectQuery>();

            objectQuery.SetupGet(x => x.DestinationElements).Returns(new List <IElement> {
                destElement.Object
            });
            objectQuery.SetupGet(x => x.Name).Returns("TestObjectQuery");

            var wordTestAdapter = new Mock <IWord2007TestReportAdapter>();

            wordTestAdapter.SetupAllProperties();

            var replacement   = new Mock <IConfigurationTestReplacement>();
            var configuration = new Mock <IConfiguration> {
                DefaultValue = DefaultValue.Mock
            };

            configuration.Setup(x => x.ConfigurationTest.GetReplacements(It.IsAny <string>())).Returns(new List <IConfigurationTestReplacement> {
                replacement.Object
            });
            configuration.SetupGet(x => x.ConfigurationTest.SetHyperlinkBase).Returns(true);
            configuration.SetupGet(x => x.ConfigurationTest.ShowHyperlinkBaseMessageBoxes).Returns(false);

            destElement.SetupGet(x => x.ItemName).Returns("Configurations");

            var helper = new TestReportHelper(_testAdapter, wordTestAdapter.Object, configuration.Object, () => false);

            if (includeOnlyMostRecentTestResults)
            {
                helper.IncludeMostRecentTestResults = true;
            }
            if (includeOnlyMostRecentTestResultForAllConfigurations)
            {
                helper.IncludeOnlyMostRecentTestResultForAllConfigurations = true;
            }

            _resultForTestCaseInAllSuitesAndPlans = helper.GetLinkedConfigurationForTestManagementObject(_testCaseDetailAllSuitesAndPlans, objectQuery.Object, false);
            _resultForTestCaseInSuite1_2_1        = helper.GetLinkedConfigurationForTestManagementObject(_testCaseDetailForTestCaseInSuite1_2_1, objectQuery.Object, false);
            _resultForTestPlan  = helper.GetLinkedConfigurationForTestManagementObject(_testPlanDetail, objectQuery.Object, false);
            _resultForTestSuite = helper.GetLinkedConfigurationForTestManagementObject(_testSuite_1_1Detail, objectQuery.Object, false);
        }
Пример #15
0
        public async Task TestGenerateTestResultReportsAsync_ReportGeneration(bool throwExceptionForTestReport1, bool throwExceptionForTestReport2, bool throwExceptionForTestReport3, int expectedReportCount)
        {
            var mockLogger = new Mock <ILogger>();
            var mockTestReportGeneratorFactory = new Mock <ITestReportGeneratorFactory>();

            string trackingId                 = "fakeTrackingId";
            var    countingReportMetadata     = new CountingReportMetadata("CountingExpectedSource", "CountingAcutalSource", TestOperationResultType.Messages, TestReportType.CountingReport);
            var    twinCountingReportMetadata = new TwinCountingReportMetadata("TwinExpectedSource", "TwinActualSource", TestReportType.TwinCountingReport, TwinTestPropertyType.Desired);
            var    deploymentReportMetadata   = new DeploymentTestReportMetadata("DeploymentExpectedSource", "DeploymentActualSource");

            var mockTestReportGenerator1 = new Mock <ITestResultReportGenerator>();

            mockTestReportGenerator1.Setup(g => g.CreateReportAsync()).Returns(this.MockTestResultReport(throwExceptionForTestReport1));

            var mockTestReportGenerator2 = new Mock <ITestResultReportGenerator>();

            mockTestReportGenerator2.Setup(g => g.CreateReportAsync()).Returns(this.MockTestResultReport(throwExceptionForTestReport2));

            var mockTestReportGenerator3 = new Mock <ITestResultReportGenerator>();

            mockTestReportGenerator3.Setup(g => g.CreateReportAsync()).Returns(this.MockTestResultReport(throwExceptionForTestReport3));

            mockTestReportGeneratorFactory.Setup(f => f.CreateAsync(trackingId, countingReportMetadata)).Returns(Task.FromResult(mockTestReportGenerator1.Object));
            mockTestReportGeneratorFactory.Setup(f => f.CreateAsync(trackingId, twinCountingReportMetadata)).Returns(Task.FromResult(mockTestReportGenerator2.Object));
            mockTestReportGeneratorFactory.Setup(f => f.CreateAsync(trackingId, deploymentReportMetadata)).Returns(Task.FromResult(mockTestReportGenerator3.Object));

            ITestResultReport[] reports = await TestReportHelper.GenerateTestResultReportsAsync(
                trackingId,
                new List <ITestReportMetadata>
            {
                countingReportMetadata,
                twinCountingReportMetadata,
                deploymentReportMetadata
            },
                mockTestReportGeneratorFactory.Object,
                mockLogger.Object);

            Assert.Equal(expectedReportCount, reports.Length);
        }
        public static void AfterScenarioWriteToReport()
        {
            ScenarioContext currentTest = ScenarioContext.Current;

            Feature.FeatureName       = FeatureContext.Current.FeatureInfo.Title;
            Scenario.ScenarioName     = Names.TestTitle;
            Scenario.Feature          = Feature;
            ExecutedTest.Scenario     = Scenario;
            ResultStatus.TestStatus   = currentTest.ScenarioExecutionStatus.ToString();
            ExecutedTest.ResultStatus = ResultStatus;

            ExecutedTest.ErrorMessage = currentTest.TestError?.Message;

            TimeSpan duration = ExecutedTest.EndTime - ExecutedTest.StartTime;

            TestReportHelper.AddTestSummary(Scenario.ScenarioName,
                                            ResultStatus.TestStatus,
                                            ExecutedTest.ErrorMessage ?? "-",
                                            duration,
                                            _actualResult,
                                            _expectedResult,
                                            File.Exists(_differenceImage) ? _differenceImage : string.Empty);
        }
Пример #17
0
        /// <summary>
        /// The method writes out the configuration information.
        /// </summary>
        private void CreateConfigurationPart()
        {
            // Get the necessary objects.
            var config     = SyncServiceFactory.GetService <IConfigurationService>().GetConfiguration(Document);
            var testReport = SyncServiceFactory.CreateWord2007TestReportAdapter(Document, config);

            // Create report helper
            var testReportHelper = new TestReportHelper(TestAdapter, testReport, config, CancellationPending);

            // Insert header of test configurations
            var templateName = config.ConfigurationTest.ConfigurationTestSpecification.TestConfigurationElementTemplate;

            testReportHelper.InsertHeaderTemplate(config.ConfigurationTest.GetHeaderTemplate(templateName));

            // Determine configurations
            var configList = new List <ITfsTestConfiguration>();

            //if (SelectedTestConfiguration.Id == AllTestConfigurations.AllTestConfigurationsId)
            //{
            foreach (var testConfiguration in TestConfigurations)
            {
                if (testConfiguration.Id == AllTestConfigurations.AllTestConfigurationsId)
                {
                    continue;
                }
                configList.Add(testConfiguration);
            }
            //}
            //else
            //    configList.Add(SelectedTestConfiguration);
            // Iterate through configurations
            foreach (var testConfiguration in configList)
            {
                testReportHelper.InsertTestConfiguration(templateName, TestAdapter.GetTestConfigurationDetail(testConfiguration));
            }
        }
Пример #18
0
        public async Task TestGenerateTestResultReportsAsync_NullReportMetadata()
        {
            var mockLogger = new Mock <ILogger>();
            var mockTestReportGeneratorFactory = new Mock <ITestReportGeneratorFactory>();

            ArgumentNullException ex = await Assert.ThrowsAsync <ArgumentNullException>(() =>
                                                                                        TestReportHelper.GenerateTestResultReportsAsync(
                                                                                            "fakeTrackngId",
                                                                                            null,
                                                                                            mockTestReportGeneratorFactory.Object,
                                                                                            mockLogger.Object));

            Assert.Equal("reportMetadatalist", ex.ParamName);
        }
Пример #19
0
        /// <summary>
        /// The method generates report by test suite structure - recursion method called from CreateReportByTestPlanHierarchy.
        /// </summary>
        /// <param name="testSuite"><see cref="ITfsTestSuite"/> is the source of test cases to write out.</param>
        /// <param name="headingLevel">Level of the heading. First level is 1.</param>
        /// <param name="firstSuite"></param>
        private void CreateReportByTestSuiteHierarchy(ITfsTestSuite testSuite, int headingLevel, bool firstSuite)
        {
            SyncServiceTrace.D("Creating report by test suite hierarchy...");
            if (testSuite == null)
            {
                SyncServiceTrace.D("Test suite is null");
                return;
            }
            // Get the necessary objects.
            var config     = SyncServiceFactory.GetService <IConfigurationService>().GetConfiguration(Document);
            var testReport = SyncServiceFactory.CreateWord2007TestReportAdapter(Document, config);
            // Get the detailed test suite.
            var testSuiteDetail = TestAdapter.GetTestSuiteDetail(testSuite);

            if (testSuiteDetail == null)
            {
                return;
            }

            var expandSharedSteps = config.ConfigurationTest.ExpandSharedSteps;
            // Check if this test suite or any child test suite contains at least one test case.
            // If no, to nothing.
            var allTestCases = TestAdapter.GetAllTestCases(testSuite, expandSharedSteps);

            if (allTestCases == null || allTestCases.Count == 0)
            {
                SyncServiceTrace.D("Given test suite does not contain tast cases.");
                return;
            }
            SyncServiceTrace.D("Number of test cases:" + allTestCases.Count);
            // Create report helper
            var testReportHelper = new TestReportHelper(TestAdapter, testReport, config, CancellationPending);

            // Insert heading
            testReportHelper.InsertHeadingText(testSuiteDetail.TestSuite.Title, headingLevel);
            var templateName = config.ConfigurationTest.ConfigurationTestSpecification.TestSuiteTemplate;

            // Insert leaf test suite template for leaf suites
            if (testSuiteDetail.TestSuite.TestSuites == null || !testSuiteDetail.TestSuite.TestSuites.Any())
            {
                templateName = config.ConfigurationTest.ConfigurationTestSpecification.LeafTestSuiteTemplate;
            }
            // Insert root test suite template: if null, root test suite template = test suite template
            if (firstSuite)
            {
                templateName = config.ConfigurationTest.ConfigurationTestSpecification.RootTestSuiteTemplate;
            }
            testReportHelper.InsertTestSuiteTemplate(templateName, testSuiteDetail);

            // Print the test configuration beneath the first testsuite
            if (!_testConfigurationInformationPrinted && IncludeTestConfigurations && SelectedConfigurationPositionType == Contracts.Enums.Model.ConfigurationPositionType.BeneathFirstTestSuite)
            {
                CreateConfigurationPart();
                _testConfigurationInformationPrinted = true;
            }


            // Get test cases of the test suite - only test cases in this test suite
            var testCases = TestAdapter.GetTestCases(testSuiteDetail.TestSuite, expandSharedSteps);

            // TestCasesHelper need document structure, but the enumerations has not value 'None'
            // We will use the functionality without this structure capability
            var helper = new TestCaseHelper(testCases, SelectedDocumentStructureType);
            // Get sorted test cases
            var sortedTestCases = helper.GetTestCases(SelectedTestCaseSortType);

            // Test if test cases exists
            if (sortedTestCases != null && sortedTestCases.Count > 0)
            {
                // Write out the common part of test case block
                templateName = config.ConfigurationTest.ConfigurationTestSpecification.TestCaseElementTemplate;
                testReportHelper.InsertHeaderTemplate(config.ConfigurationTest.GetHeaderTemplate(templateName));
                // Iterate all test cases
                foreach (var testCase in sortedTestCases)
                {
                    if (CancellationPending())
                    {
                        return;
                    }
                    // Write out the test case part
                    testReportHelper.InsertTestCase(templateName, testCase);
                }
            }

            // Check child suites
            if (testSuiteDetail.TestSuite.TestSuites != null)
            {
                // Iterate through child test suites
                foreach (var childTestSuite in testSuiteDetail.TestSuite.TestSuites)
                {
                    if (CancellationPending())
                    {
                        return;
                    }
                    CreateReportByTestSuiteHierarchy(childTestSuite, headingLevel + 1, false);
                }
            }

            //Print the configuration information beneath all TestSuites
            if (IncludeTestConfigurations && SelectedConfigurationPositionType == Contracts.Enums.Model.ConfigurationPositionType.BeneathTestSuites)
            {
                CreateConfigurationPart();
            }
        }
Пример #20
0
        /// <summary>
        /// The method creates report structured by iteration path.
        /// </summary>
        /// <param name="testSuite"><see cref="ITfsTestSuite"/> is the source of test cases to write out.</param>
        private void CreateReportByIterationPath(ITfsTestSuite testSuite)
        {
            SyncServiceTrace.D("Creating report by iteration path...");
            if (testSuite == null)
            {
                SyncServiceTrace.D("Test suite is null");
                return;
            }
            // Get the necessary objects.
            var config     = SyncServiceFactory.GetService <IConfigurationService>().GetConfiguration(Document);
            var testReport = SyncServiceFactory.CreateWord2007TestReportAdapter(Document, config);
            // Get the detailed test plan.
            var testPlanDetail = TestAdapter.GetTestPlanDetail(testSuite);

            if (testPlanDetail == null)
            {
                return;
            }
            // Get the detailed test suite.
            var testSuiteDetail = TestAdapter.GetTestSuiteDetail(testSuite);

            if (testSuiteDetail == null)
            {
                return;
            }

            // Create report helper
            var testReportHelper = new TestReportHelper(TestAdapter, testReport, config, CancellationPending);
            // Insert test plan template
            var templateName = config.ConfigurationTest.ConfigurationTestSpecification.TestPlanTemplate;

            testReportHelper.InsertTestPlanTemplate(templateName, testPlanDetail);
            // Insert test suite template
            templateName = config.ConfigurationTest.ConfigurationTestSpecification.RootTestSuiteTemplate;
            testReportHelper.InsertTestSuiteTemplate(templateName, testSuiteDetail);

            // TODO MIS THIS IS THE ONLY PLACE WHERE GetAllTestCases can be called in context of the configuration template... Check late if it is enough only extend GetAllTestCases for at this single place here with the additional parameter
            // Get test cases of the test suite - with test cases in sub test suites
            var expandSharedSteps = config.ConfigurationTest.ExpandSharedSteps;
            var testCases         = TestAdapter.GetAllTestCases(testSuiteDetail.TestSuite, expandSharedSteps);

            SyncServiceTrace.D("Number of test cases:" + testCases.Count);
            // Create test case helper
            var helper = new TestCaseHelper(testCases, SelectedDocumentStructureType);
            // Get all path elements from all test cases
            var pathElements = helper.GetPathElements(SkipLevels);

            // Iterate through path elements
            foreach (var pathElement in pathElements)
            {
                // Insert heading
                testReportHelper.InsertHeadingText(pathElement.PathPart, pathElement.Level - SkipLevels);
                // Get sorted test cases
                var sortedTestCases = helper.GetTestCases(pathElement, SelectedTestCaseSortType);
                if (sortedTestCases != null && sortedTestCases.Count > 0)
                {
                    // Write out the common part of test case block
                    templateName = config.ConfigurationTest.ConfigurationTestSpecification.TestCaseElementTemplate;
                    testReportHelper.InsertHeaderTemplate(config.ConfigurationTest.GetHeaderTemplate(templateName));
                    // Iterate all test cases
                    foreach (var testCase in sortedTestCases)
                    {
                        if (CancellationPending())
                        {
                            return;
                        }
                        // Write out the test case part
                        testReportHelper.InsertTestCase(templateName, testCase);
                    }
                }
            }
            // Remove the inserted bookmarks
            testReport.RemoveBookmarks();

            // Common part
            if (IncludeTestConfigurations && SelectedConfigurationPositionType == Contracts.Enums.Model.ConfigurationPositionType.BeneathTestPlan)
            {
                CreateConfigurationPart();
            }
        }
Пример #21
0
        /// <summary>
        /// The method creates unstructured report - writes out all test cases in one block.
        /// </summary>
        /// <param name="testSuite"><see cref="ITfsTestSuite"/> is the source of test cases to write out.</param>
        private void CreateReportUnstructured(ITfsTestSuite testSuite)
        {
            if (testSuite == null)
            {
                return;
            }
            // Get the necessary objects.
            var config     = SyncServiceFactory.GetService <IConfigurationService>().GetConfiguration(Document);
            var testReport = SyncServiceFactory.CreateWord2007TestReportAdapter(Document, config);
            // Get the detailed test plan.
            var testPlanDetail = TestAdapter.GetTestPlanDetail(testSuite);

            if (testPlanDetail == null)
            {
                return;
            }
            // Get the detailed test suite.
            var testSuiteDetail = TestAdapter.GetTestSuiteDetail(testSuite);

            if (testSuiteDetail == null)
            {
                return;
            }

            // Create report helper
            var testReportHelper = new TestReportHelper(TestAdapter, testReport, config, CancellationPending);
            // Insert test plan template
            var templateName = config.ConfigurationTest.ConfigurationTestSpecification.TestPlanTemplate;

            testReportHelper.InsertTestPlanTemplate(templateName, testPlanDetail);

            // Common part
            if (IncludeTestConfigurations && SelectedConfigurationPositionType == Contracts.Enums.Model.ConfigurationPositionType.BeneathTestPlan)
            {
                CreateConfigurationPart();
            }

            // Insert test suite template
            templateName = config.ConfigurationTest.ConfigurationTestSpecification.RootTestSuiteTemplate;
            var expandSharedSteps = config.ConfigurationTest.ExpandSharedSteps;

            testReportHelper.InsertTestSuiteTemplate(templateName, testSuiteDetail);

            // Get test cases of the test suite - with test cases in sub test suites
            var testCases = TestAdapter.GetAllTestCases(testSuiteDetail.TestSuite, expandSharedSteps);

            // TestCasesHelper need document structure, but the enumerations has not value 'None'
            // We will use the functionality without this structure capability
            var helper = new TestCaseHelper(testCases, SelectedDocumentStructureType);
            // Get sorted test cases
            var sortedTestCases = helper.GetTestCases(SelectedTestCaseSortType);

            // Test if test cases exists
            if (sortedTestCases != null && sortedTestCases.Count > 0)
            {
                // Write out the common part of test case block
                templateName = config.ConfigurationTest.ConfigurationTestSpecification.TestCaseElementTemplate;
                testReportHelper.InsertHeaderTemplate(config.ConfigurationTest.GetHeaderTemplate(templateName));
                // Iterate all test cases
                foreach (var testCase in sortedTestCases)
                {
                    if (CancellationPending())
                    {
                        return;
                    }
                    // Write out the test case part
                    testReportHelper.InsertTestCase(templateName, testCase);
                }
            }
        }
Пример #22
0
        /// <summary>
        /// The method creates report for selected test suite.
        /// </summary>
        public void CreateReport()
        {
            SyncServiceTrace.D("Creating report...");
            SyncServiceDocumentModel.TestReportRunning = true;
            try
            {
                ProcessPreOperations();

                // Common part
                if (IncludeTestConfigurations && SelectedConfigurationPositionType == Contracts.Enums.Model.ConfigurationPositionType.AboveTestPlan)
                {
                    CreateConfigurationPart();
                }
                if (CreateDocumentStructure)
                {
                    switch (SelectedDocumentStructureType)
                    {
                    case DocumentStructureType.AreaPath:
                        CreateReportByAreaPath(SelectedTestSuite);
                        break;

                    case DocumentStructureType.IterationPath:
                        CreateReportByIterationPath(SelectedTestSuite);
                        break;

                    case DocumentStructureType.TestPlanHierarchy:
                        CreateReportByTestPlanHierarchy(SelectedTestSuite);
                        break;
                    }
                }
                else
                {
                    CreateReportUnstructured(SelectedTestSuite);
                }
                if (!CancellationPending())
                {
                    // Set the 'Report generated' only if the report was not canceled
                    SyncServiceDocumentModel.TestReportGenerated = true;
                    if (ViewDispatcher != null)
                    {
                        ViewDispatcher.Invoke(() => CreateReportCommand.CallEventCanExecuteChanged());
                    }
                    StoreReportData();
                }


                var config           = SyncServiceFactory.GetService <IConfigurationService>().GetConfiguration(Document);
                var testReport       = SyncServiceFactory.CreateWord2007TestReportAdapter(Document, config);
                var testReportHelper = new TestReportHelper(TestAdapter, testReport, config, CancellationPending);

                if (TestReportingProgressCancellationService.CheckIfContinue())
                {
                    testReportHelper.CreateSummaryPage(WordDocument, SelectedTestPlan);
                    ProcessPostOperations();
                }
                else
                {
                    SyncServiceTrace.I("Skipped creation of summary page and processing post operations because of error or cancellation.");
                }
            }
            catch (Exception ex)
            {
                var infoStorageService = SyncServiceFactory.GetService <IInfoStorageService>();
                if (infoStorageService == null)
                {
                    throw;
                }
                IUserInformation info = new UserInformation
                {
                    Text        = Resources.TestSpecification_Error,
                    Explanation = ex is OperationCanceledException ? ex.Message : ex.ToString(),
                    Type        = UserInformationType.Error
                };
                infoStorageService.AddItem(info);
            }
            finally
            {
                SyncServiceDocumentModel.TestReportRunning = false;
            }
        }
Пример #23
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);
        }
 public static void BeforeAddReportContent()
 {
     TestReportHelper.CreateStructure();
 }
 public static void AfterTestRunWriteToReport()
 {
     TestReportHelper.AddSummary();
     TestReportHelper.WriteToReport(Names.TestReportPath);
 }
        /// <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="DoWorkEventArgs"/> that contains the event data.</param>
        public void DoImport(object sender, DoWorkEventArgs e)
        {
            SyncServiceTrace.I(Resources.ImportWorkItems);
            var workItemSyncService = SyncServiceFactory.GetService <IWorkItemSyncService>();
            var configService       = SyncServiceFactory.GetService <IConfigurationService>();

            // save query configuration to document
            DocumentModel.SaveQueryConfiguration(_queryConfiguration);
            DocumentModel.Save();

            // set actual selected configuration
            var configuration = configService.GetConfiguration(WordDocument);

            _importTestReport = SyncServiceFactory.CreateWord2007TestReportAdapter(WordDocument, configuration);

            var ignoreFormatting  = configuration.IgnoreFormatting;
            var conflictOverwrite = configuration.ConflictOverwrite;

            configuration.ActivateMapping(DocumentModel.MappingShowName);
            DocumentModel.Configuration.IgnoreFormatting = ignoreFormatting;
            configuration.ConflictOverwrite = conflictOverwrite;
            configuration.IgnoreFormatting  = ignoreFormatting;

            var source          = SyncServiceFactory.CreateTfs2008WorkItemSyncAdapter(DocumentModel.TfsServer, DocumentModel.TfsProject, null, configuration);
            var destination     = SyncServiceFactory.CreateWord2007TableWorkItemSyncAdapter(WordDocument, configuration);
            var importWorkItems = (from wim in FoundWorkItems
                                   where wim.IsChecked
                                   select wim.Item).ToList();

            if (!(source.Open(importWorkItems.Select(x => x.TfsItem.Id).ToArray()) && destination.Open(null)))
            {
                return;
            }

            // Check for test cases.
            var expandSharedsteps = configuration.ConfigurationTest.ExpandSharedSteps;
            var testCases         = GetTestCasesFromWorkItems(importWorkItems, expandSharedsteps);

            // Check for shared steps
            var sharedSteps = GetSharedStepsFromWorkItems(importWorkItems);

            //Get any pre and post operations for the reports
            var preOperations  = configuration.ConfigurationTest.GetPreOperationsForTestSpecification();
            var postOperations = configuration.ConfigurationTest.GetPostOperationsForTestSpecification();

            var testReportHelper = new TestReportHelper(_testAdapter, _importTestReport, configuration, () => !IsImporting);

            _importTestReport.PrepareDocumentForLongTermOperation();
            testReportHelper.ProcessOperations(preOperations);

            if (testCases.Count > 0 && sharedSteps.Count > 0)
            {
                throw new ConfigurationException("Function can only be used for either shared steps or test cases. Select only work items of one Type.");
            }
            if (testCases.Count > 0)
            {
                workItemSyncService.RefreshAndSubstituteTestItems(source, destination, importWorkItems.Select(x => x.TfsItem), configuration, testReportHelper, testCases);
            }
            if (sharedSteps.Count > 0)
            {
                workItemSyncService.RefreshAndSubstituteSharedStepItems(source, destination, importWorkItems.Select(x => x.TfsItem), configuration, testReportHelper, sharedSteps);
            }
            // when cancelled by the user skip further steps
            var progressService = SyncServiceFactory.GetService <IProgressService>();

            if (null != progressService && !progressService.ProgressCanceled)
            {
                testReportHelper.CreateSummaryPage(WordDocument, null);
                testReportHelper.ProcessOperations(postOperations);
            }
            else
            {
                SyncServiceTrace.I("Skipped");
            }

            DocumentModel.TestReportGenerated = true;
        }