Exemplo n.º 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);
        }
Exemplo n.º 2
0
 private void Test(ITfsTestSuite rootSuite)
 {
     Debug.WriteLine(rootSuite.Title);
     foreach (var suite in rootSuite.TestSuites)
     {
         Test(suite);
     }
 }
Exemplo n.º 3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Word2007TestReportAdapter"/> class.
 /// </summary>
 /// <param name="document">Word document to work with.</param>
 /// <param name="configuration">The configuration.</param>
 /// <param name="testSuite">The test suite</param>
 /// <param name="allTestCases">All test cases related to test suite</param>
 public Word2007TestReportAdapter(Document document, IConfiguration configuration, ITfsTestSuite testSuite, IList <ITfsTestCaseDetail> allTestCases)
 {
     _document                  = document;
     _configuration             = configuration;
     _preparationDocumentHelper = new PreparationDocumentHelper(_document, _wordApplication);
     _testSuite                 = testSuite;
     _allTestCases              = allTestCases;
 }
Exemplo n.º 4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TestSpecificationReportModel"/> class for the console extension
 /// </summary>
 /// <param name="syncServiceDocumentModel">The <see cref="ISyncServiceModel"/> to obtain document settings.</param>
 /// <param name="testAdapter"><see cref="ITfsTestAdapter"/> to examine test information.</param>
 /// <param name="sort"></param>
 /// <param name="testReportingProgressCancellationService">The progess cancellation service used to check at certain points if a cancellation has been triggered and further steps should be skipped.</param>
 /// <param name="plan">The selected <see cref="ITfsTestPlan"/> used for the report generation.</param>
 /// <param name="suite">The selected <see cref="ITfsTestSuite"/> used for the report generation.</param>
 /// <param name="documentStructure">The information if a document structure should be created.</param>
 /// <param name="skipLevels">The level count to ignore generation.</param>
 /// <param name="structureType"></param>
 public TestSpecificationReportModel(ISyncServiceDocumentModel syncServiceDocumentModel, ITfsTestAdapter testAdapter, ITfsTestPlan plan, ITfsTestSuite suite, bool documentStructure, int skipLevels, DocumentStructureType structureType, TestCaseSortType sort, ITestReportingProgressCancellationService testReportingProgressCancellationService)
     : base(syncServiceDocumentModel, testAdapter, testReportingProgressCancellationService)
 {
     SelectedTestPlan        = plan;
     SelectedTestSuite       = suite;
     CreateDocumentStructure = documentStructure;
     SkipLevels = skipLevels;
     SelectedDocumentStructureType = structureType;
     SelectedTestCaseSortType      = sort;
     CreateReportCommand           = new ViewCommand(ExecuteCreateReportCommand, CanExecuteCreateReportCommand);
     WordDocument = syncServiceDocumentModel.WordDocument as Document;
 }
Exemplo n.º 5
0
        private ITfsTestSuite SearchTestSuite(IEnumerable <ITfsTestSuite> suites, string testSuitePath)
        {
            string potentialErrorMessage;

            if (testSuitePath.Contains('/'))
            {
                _originalTestPath     = testSuitePath;
                _suite                = SearchTestSuiteByPath(suites, testSuitePath);
                potentialErrorMessage = Resources.TestSuitePathCouldNotBeFound;
            }
            else
            {
                _suite = SearchtestSuiteByName(suites, testSuitePath);
                potentialErrorMessage = Resources.TestSuiteNameCouldNotBeFound;
            }

            if (_suite == null)
            {
                SyncServiceTrace.D(Resources.TestSuiteNotExist);
                throw new ArgumentException(string.Format(potentialErrorMessage, testSuitePath));
            }

            return(_suite);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Method gets the interface of new object that implements
        /// the <see cref="IWord2007TestReportAdapter"/> interface for word document - test report implementation.
        /// </summary>
        /// <param name="document">Word document to work with.</param>
        /// <param name="configuration">Configuration to use.</param>
        /// <param name="testSuite">The test suite.</param>
        /// <param name="allTestCases">All test cases that test suite contains.</param>
        /// <returns>Created object.</returns>
        public static IWord2007TestReportAdapter CreateWord2007TestReportAdapter(object document, IConfiguration configuration, ITfsTestSuite testSuite, IList <ITfsTestCaseDetail> allTestCases)
        {
            var service = GetService <IWord2007AdapterCreator>();

            return(service == null ? null : service.CreateTestReportAdapter(document, configuration, testSuite, allTestCases));
        }
Exemplo n.º 7
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();
            }
        }
Exemplo n.º 8
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();
            }
        }
Exemplo n.º 9
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);
                }
            }
        }
Exemplo n.º 10
0
 /// <summary>
 /// Creates an instance of word 2007 test report adapter.
 /// </summary>
 /// <param name="document">Word document to work with.</param>
 /// <param name="configuration">Configuration to use.</param>
 /// <param name="testSuite">Test suite.</param>
 ///  <param name="allTestCases">All test cases that test suite contains.</param>
 /// <returns>Created adapter.</returns>
 public IWord2007TestReportAdapter CreateTestReportAdapter(object document, IConfiguration configuration, ITfsTestSuite testSuite, IList <ITfsTestCaseDetail> allTestCases)
 {
     return(new Word2007TestReportAdapter(document as Document, configuration, testSuite, allTestCases));
 }