public TestReportCollection Run() { bool showTestingBrowserHost = _options.ShowTestingBrowserHost; bool useRemoteTestPage = _options.UseRemoteTestPage; Collection <string> methodsToTest = _options.MethodsToTest; MicrosoftTestingFrameworkVersion?microsoftTestingFrameworkVersion = _options.MicrosoftTestingFrameworkVersion; string tagFilters = _options.TagFilters; UnitTestProviderType unitTestProviderType = _options.UnitTestProviderType; int numberOfBrowserHosts = _options.NumberOfBrowserHosts; string queryString = _options.QueryString; WebBrowserType webBrowserType = _options.WebBrowserType; bool forceBrowserStart = _options.ForceBrowserStart; IEnumerable <string> xapPaths = _options.XapPaths; IEnumerable <string> testDlls = _options.Dlls; _options.DumpValuesForDebug(_logger); var runnerType = GetRunnerType(); _logger.Debug("RunnerType = {0}".FormatWith(runnerType)); var testReports = new TestReportCollection(); foreach (var xapPath in xapPaths) { _logger.Debug("Starting configuration for: {0}".FormatWith(xapPath)); StatLightConfiguration statLightConfiguration = _statLightConfigurationFactory .GetStatLightConfigurationForXap( unitTestProviderType, xapPath, microsoftTestingFrameworkVersion, methodsToTest, tagFilters, numberOfBrowserHosts, useRemoteTestPage, queryString, webBrowserType, forceBrowserStart, showTestingBrowserHost); var testReport = DoTheRun(runnerType, statLightConfiguration); testReports.Add(testReport); } foreach (var dllPath in testDlls) { _logger.Debug("Starting configuration for: {0}".FormatWith(dllPath)); StatLightConfiguration statLightConfiguration = _statLightConfigurationFactory .GetStatLightConfigurationForDll( unitTestProviderType, dllPath, microsoftTestingFrameworkVersion, methodsToTest, tagFilters, numberOfBrowserHosts, useRemoteTestPage, queryString, webBrowserType, forceBrowserStart, showTestingBrowserHost); var testReport = DoTheRun(runnerType, statLightConfiguration); testReports.Add(testReport); } string xmlReportOutputPath = _options.XmlReportOutputPath; bool tfsGenericReport = _options.TFSGenericReport; XmlReportType xmlReportType = XmlReportType.StatLight; if (tfsGenericReport) { xmlReportType = XmlReportType.TFS; } WriteXmlReport(testReports, xmlReportOutputPath, xmlReportType); return(testReports); }
private static void WriteXmlReport(TestReportCollection testReports, string xmlReportOutputPath, XmlReportType xmlReportType) { if (!string.IsNullOrEmpty(xmlReportOutputPath)) { IXmlReport xmlReport = null; switch (xmlReportType) { case XmlReportType.TFS: xmlReport = new Core.Reporting.Providers.TFS.TFS2010.XmlReport(testReports); break; case XmlReportType.StatLight: xmlReport = new XmlReport(testReports); break; default: throw new StatLightException("Unknown XmlReportType chosen Name=[{0}], Value=[{1}]".FormatWith(xmlReportType.ToString(), (int)xmlReportType)); } xmlReport.WriteXmlReport(xmlReportOutputPath); "*********************************" .WrapConsoleMessageWithColor(Settings.Default.ConsoleColorInformatoin, true); "Wrote XML report to:{0}{1}" .FormatWith(Environment.NewLine, new FileInfo(xmlReportOutputPath).FullName) .WrapConsoleMessageWithColor(Settings.Default.ConsoleColorWarning, true); "*********************************" .WrapConsoleMessageWithColor(Settings.Default.ConsoleColorInformatoin, true); } }