CreateSuitesXElementWithParameters() public method

public CreateSuitesXElementWithParameters ( IOrderedEnumerable suites, IOrderedEnumerable scenarios, IOrderedEnumerable testResults, IXMLElementsStruct xmlStruct ) : System.Xml.Linq.XElement
suites IOrderedEnumerable
scenarios IOrderedEnumerable
testResults IOrderedEnumerable
xmlStruct IXMLElementsStruct
return System.Xml.Linq.XElement
        protected override void BeginProcessing()
        {
            CheckCmdletParameters();

            var cmdlet = new SearchCmdletBase {FilterAll = true};

            // 20140720
//            var dataObject = new SearchCmdletBaseDataObject {
//                FilterAll = true
//            };
            // 20140721
            var dataObject = new SearchCmdletBaseDataObject {
                Descending = cmdlet.Descending,
                FilterAll = cmdlet.FilterAll,
                FilterDescriptionContains = cmdlet.FilterDescriptionContains,
                FilterFailed = cmdlet.FilterFailed,
                FilterIdContains = cmdlet.FilterIdContains,
                FilterNameContains = cmdlet.FilterNameContains,
                FilterNone = cmdlet.FilterNone,
                FilterNotTested = cmdlet.FilterNotTested,
                FilterOutAutomaticAndTechnicalResults = cmdlet.FilterOutAutomaticAndTechnicalResults,
                FilterOutAutomaticResults = cmdlet.FilterOutAutomaticResults,
                FilterPassed = cmdlet.FilterPassed,
                FilterPassedWithBadSmell = cmdlet.FilterPassedWithBadSmell,
                Id = cmdlet.Id,
                Name = cmdlet.Name,
                OrderByDateTime = cmdlet.OrderByDateTime,
                OrderByFailRate = cmdlet.OrderByFailRate,
                OrderById = cmdlet.OrderById,
                OrderByName = cmdlet.OrderByName,
                OrderByPassRate = cmdlet.OrderByPassRate,
                OrderByTimeSpent = cmdlet.OrderByTimeSpent
            };
            // IOrderedEnumerable<TestSuite> suites =
            IOrderedEnumerable<ITestSuite> suites = TmxHelper.SearchForSuites(dataObject);
            
cmdlet.FilterNone = true;
            
            IOrderedEnumerable<ITestScenario> scenarios = TmxHelper.SearchForScenarios(dataObject);

            //cmdlet.FilterAll = false;
            //cmdlet.FilterPassedWithBadSmell = true;
//            cmdlet.FilterNone = true;
            
            IOrderedEnumerable<ITestResult> testResults = TmxHelper.SearchForTestResults(dataObject);
            
            // 20141124
//            XElement suitesElement = 
//                TmxHelper.CreateSuitesXElementWithParameters(
//                    suites,
//                    scenarios,
//                    testResults,
//                    (new XMLElementsNativeStruct()));
            
            var testResultsExporter = new TestResultsExporter();
            var suitesElement = testResultsExporter.CreateSuitesXElementWithParameters(
                suites,
                scenarios,
                testResults,
                (new XMLElementsNativeStruct()));
            
            WriteObject(this, suitesElement);

        }
示例#2
0
        public static void ExportResultsToJUnitXML(ISearchCmdletBaseDataObject cmdlet, string path)
        {
            try {

                var gathered = new GatherTestResultsCollections();
                gathered.GatherCollections(cmdlet);
                
                var testResultsExporter = new TestResultsExporter();
                var suitesElement = testResultsExporter.CreateSuitesXElementWithParameters(
                    gathered.TestSuites,
                    gathered.TestScenarios,
                    gathered.TestResults,
                    (new XMLElementsJUnitStruct()));
                
                var document = new XDocument();
                document.Add(suitesElement);
                document.Save(path);
            }
            catch (Exception eCreateDocument) {
                // 20140720
//                cmdlet.WriteError(
//                    cmdlet,
//                    "Unable to save XML report to the file '" +
//                    path +
//                    "'. " + 
//                    eCreateDocument.Message,
//                    "FailedToSaveReport",
//                    ErrorCategory.InvalidOperation,
//                    true);
                throw new Exception(
                    "Unable to save XML report to the file '" +
                    path +
                    "'. " + 
                    eCreateDocument.Message);
            }
        }