Ejemplo n.º 1
0
        private void Launch(bool doNoRun)
        {
            MarkupStreamWriter logStreamWriter = TestLog.Default;

            var launcher = new TestLauncher();

            launcher.TestProject.TestPackage = testPackage;
            launcher.Logger = new MarkupStreamLogger(logStreamWriter);
            launcher.TestExecutionOptions.FilterSet    = new FilterSet <ITestDescriptor>(new OrFilter <ITestDescriptor>(filters));
            launcher.TestProject.TestRunnerFactoryName = TestRunnerFactoryName;

            string reportDirectory = SpecialPathPolicy.For <SampleRunner>().GetTempDirectory().FullName;

            launcher.TestProject.ReportDirectory  = reportDirectory;
            launcher.TestProject.ReportNameFormat = "SampleRunnerReport";
            launcher.ReportFormatterOptions.AddProperty(@"SaveAttachmentContents", @"false");
            launcher.AddReportFormat(@"Text");
            // Disabled because the Xml can get really big and causes problems if the sample runner is used frequently.
            //launcher.AddReportFormat("Xml");

            launcher.DoNotRun = doNoRun;

            GenericCollectionUtils.ForEach(testRunnerOptions.Properties, x => launcher.TestRunnerOptions.AddProperty(x.Key, x.Value));

            using (logStreamWriter.BeginSection("Log Output"))
                result = launcher.Run();

            using (logStreamWriter.BeginSection("Text Report"))
            {
                foreach (string reportPath in result.ReportDocumentPaths)
                {
                    string extension = Path.GetExtension(reportPath);
                    if (extension == ".txt")
                    {
                        logStreamWriter.WriteLine(File.ReadAllText(reportPath));
                    }
                    else if (extension == ".xml")
                    {
                        logStreamWriter.Container.AttachXml(null, File.ReadAllText(reportPath));
                    }

                    File.Delete(reportPath);
                }
            }
        }
Ejemplo n.º 2
0
        private void Launch(bool doNoRun)
        {
            MarkupStreamWriter logStreamWriter = TestLog.Default;

            var launcher = new TestLauncher();
            launcher.TestProject.TestPackage = testPackage;
            launcher.Logger = new MarkupStreamLogger(logStreamWriter);
            launcher.TestExecutionOptions.FilterSet = new FilterSet<ITestDescriptor>(new OrFilter<ITestDescriptor>(filters));
            launcher.TestProject.TestRunnerFactoryName = TestRunnerFactoryName;

            string reportDirectory = SpecialPathPolicy.For<SampleRunner>().GetTempDirectory().FullName;
            launcher.TestProject.ReportDirectory = reportDirectory;
            launcher.TestProject.ReportNameFormat = "SampleRunnerReport";
            launcher.ReportFormatterOptions.AddProperty(@"SaveAttachmentContents", @"false");
            launcher.AddReportFormat(@"Text");
            // Disabled because the Xml can get really big and causes problems if the sample runner is used frequently.
            //launcher.AddReportFormat("Xml");

            launcher.DoNotRun = doNoRun;

            GenericCollectionUtils.ForEach(testRunnerOptions.Properties, x => launcher.TestRunnerOptions.AddProperty(x.Key, x.Value));

            using (logStreamWriter.BeginSection("Log Output"))
                result = launcher.Run();

            using (logStreamWriter.BeginSection("Text Report"))
            {
                foreach (string reportPath in result.ReportDocumentPaths)
                {
                    string extension = Path.GetExtension(reportPath);
                    if (extension == ".txt")
                    {
                        logStreamWriter.WriteLine(File.ReadAllText(reportPath));
                    }
                    else if (extension == ".xml")
                    {
                        logStreamWriter.Container.AttachXml(null, File.ReadAllText(reportPath));
                    }

                    File.Delete(reportPath);
                }
            }
        }