/// <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); }
/// <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(); } }
/// <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); } } }