Ejemplo n.º 1
0
    public void RunFinished(TestResult result)
    {
        // Reset console output
        consoleStringWriter.Dispose();
        var consoleOut = Console.Out;

        Console.SetOut(consoleOut);

        // Write the TestResult.xml
        if (testresultpath != null)
        {
            var testResultBuilder = new StringBuilder();
            using (var writer = new StringWriter(testResultBuilder))
            {
                var xmlWriter = new XmlResultWriter(writer);
                xmlWriter.SaveTestResult(result);
            }

            var xmlOutput = testResultBuilder.ToString();
            using (var writer = new StreamWriter(testresultpath))
            {
                writer.Write(xmlOutput);
            }
        }
    }
Ejemplo n.º 2
0
 /// <summary>
 /// Saves the TestResult as xml to the specified path.
 /// </summary>
 /// <param name="result">The test result to be saved.</param>
 /// <param name="outputXmlPath">The output xml path.</param>
 private static void SaveXmlOutput(TestResult result, string outputXmlPath)
 {
     if (!string.IsNullOrEmpty(outputXmlPath))
     {
         var writer = new XmlResultWriter(outputXmlPath);
         writer.SaveTestResult(result);
     }
 }
Ejemplo n.º 3
0
        public TestRunner(String path)
        {
            this.path = path;
            TestResult      tempTr = runTest();
            XmlResultWriter xmlw   = new XmlResultWriter(Directory.GetCurrentDirectory() + @"\BackupResults\testResult_" + this.nextFileName());

            xmlw.SaveTestResult(tempTr);
            //call class to xml parsing
        }
Ejemplo n.º 4
0
        private TestResult runTest()
        {
            CoreExtensions.Host.InitializeService();
            TestPackage      testPackage = new TestPackage(this.path);
            RemoteTestRunner rtr         = new RemoteTestRunner();

            rtr.Load(testPackage);
            TestResult      tr   = rtr.Run(new NullListener(), TestFilter.Empty, false, LoggingThreshold.Error);
            XmlResultWriter xmlw = new XmlResultWriter(Directory.GetCurrentDirectory() + @"\TempResults\testResult.xml");

            xmlw.SaveTestResult(tr);
            return(tr);
        }
        protected void OutputXml(TestResult result)
        {
            var builder      = new StringBuilder();
            var writer       = new StringWriter(builder);
            var resultWriter = new XmlResultWriter(writer);

            resultWriter.SaveTestResult(result);

            Response.ContentType = "text/xml";
            Response.Write(builder.ToString());
            Response.Flush();
            Response.End();
        }
Ejemplo n.º 6
0
 public void RunFinished(TestResult result)
 {
     try
     {
         var cleanedName = OutputName.Replace("?", "");
         var writer      = new XmlResultWriter(Path.Combine(_outputPath, string.Format("{0}.xml", cleanedName)));
         writer.SaveTestResult(result);
     }
     finally
     {
         //Finished
         MarkAsFinished();
     }
 }
Ejemplo n.º 7
0
        private void OnRunAllTests()
        {
            LinkedWindow.Close();

            List <string> copiedAssemblies = new List <string>();

            foreach (TestableDll dll in DLLs)
            {
                // Shadow copy to temp folder
                string tempFile = Path.GetTempFileName();
                tempFile = tempFile.Replace(Path.GetExtension(tempFile), Path.GetExtension(dll.FullPath));
                File.Copy(dll.FullPath, tempFile, true);

                //Copy the PDB to get stack trace
                string destPdbFile = tempFile.Replace(Path.GetExtension(tempFile), ".pdb");
                string srcPdb      = dll.FullPath.Replace(Path.GetExtension(dll.FullPath), ".pdb");
                File.Copy(srcPdb, destPdbFile, true);

                copiedAssemblies.Add(tempFile);
            }

            // Copy Moq.dll and dependencies to temp folder
            CopyRequiredLibsToTemp(DLLs.First().FullPath);

            TestResult testResult = RunTestsInAssemblies(copiedAssemblies, TestFilter.Empty);

            // Save the result to xml file:
            string          resultFile   = Path.GetDirectoryName(DLLs.First().FullPath) + @"\TestResult.xml";
            XmlResultWriter resultWriter = new XmlResultWriter(resultFile);

            resultWriter.SaveTestResult(testResult);

            // show results dialog
            string extraMsg = "Result file can be found at " + resultFile;
            TestResultViewerViewModel vm     = new TestResultViewerViewModel(testResult, extraMsg);
            TestResultViewer          viewer = new TestResultViewer(vm);

            //viewer.Owner = LinkedWindow;
            GeneralHelper.SetRevitAsWindowOwner(viewer);
            viewer.ShowDialog();

            // cleanup
            foreach (string dll in copiedAssemblies)
            {
                File.Delete(dll);
                File.Delete(Path.ChangeExtension(dll, ".pdb"));
            }
        }
Ejemplo n.º 8
0
        private void OnRunTest(string testDll)
        {
            string originalDllName = testDll;

            LinkedWindow.Close();
            // Shadow copy to temp folder
            string tempFile = Path.GetTempFileName();

            tempFile = tempFile.Replace(Path.GetExtension(tempFile), Path.GetExtension(testDll));
            File.Copy(testDll, tempFile, true);

            //Copy the PDB to get stack trace
            string destPdbFile = tempFile.Replace(Path.GetExtension(tempFile), ".pdb");
            string srcPdb      = testDll.Replace(Path.GetExtension(testDll), ".pdb");

            File.Copy(srcPdb, destPdbFile, true);

            testDll = tempFile;

            // Copy Moq.dll and dependencies to temp folder
            CopyRequiredLibsToTemp(tempFile);

            SimpleTestFilter filter     = new SimpleTestFilter(DLLs.FirstOrDefault(d => d.FullPath == originalDllName).Tests);
            TestResult       testResult = RunTestsInAssemblies(new List <string>()
            {
                testDll
            }, filter);

            // Save the result to xml file:
            string          resultFile   = Path.GetDirectoryName(testDll) + @"\TestResult.xml";
            XmlResultWriter resultWriter = new XmlResultWriter(resultFile);

            resultWriter.SaveTestResult(testResult);

            // show results dialog
            string extraMsg = "Result file can be found at " + resultFile;
            TestResultViewerViewModel vm     = new TestResultViewerViewModel(testResult, extraMsg);
            TestResultViewer          viewer = new TestResultViewer(vm);

            //viewer.Owner = LinkedWindow;
            GeneralHelper.SetRevitAsWindowOwner(viewer);
            viewer.ShowDialog();

            // cleanup
            File.Delete(tempFile);
            File.Delete(destPdbFile);
        }
Ejemplo n.º 9
0
            public override void RunFinished(TestResult result)
            {
                base.RunFinished(result);

                var resultWriter = new XmlResultWriter(_runOptions.XmlResultsPath);

                resultWriter.SaveTestResult(result);

                if (_runOptions.PerformXslTransform)
                {
                    var transform = new XslCompiledTransform();
                    transform.Load(_runOptions.XslTransformPath);
                    transform.Transform(_runOptions.XmlResultsPath, _runOptions.TransformedResultsPath);
                }

                File.WriteAllText(_runOptions.StdoutPath, StdoutStandin.ToString());

                if (_runOptions.PerformXslTransform && _runOptions.ShouldLaunchResults)
                {
                    System.Diagnostics.Process.Start(_runOptions.TransformedResultsPath);
                }
            }
Ejemplo n.º 10
0
Archivo: Program.cs Proyecto: zparr/ATF
        /// <summary>
        /// Runs all tests.
        /// </summary>
        /// <param name="testAssemblyName">Name of the test assembly.</param>
        /// <returns>0 if tests ran successfully, -1 otherwise</returns>
        public static int RunAllTests(string testAssemblyName)
        {
            TestRunner runner   = MakeTestRunner(testAssemblyName);
            string     category = ParseTestCategory();

            runner.Run(new UnitTestListener(), new TestFilter(category));
            XmlResultWriter writer = new XmlResultWriter("TestResult.xml");

            writer.SaveTestResult(runner.TestResult);

            XslCompiledTransform xsl = new XslCompiledTransform();

            xsl.Load("Resources/NUnitToJUnit.xslt");
            xsl.Transform("TestResult.xml", "TestResult.JUnit.xml");

            if (runner.TestResult.IsFailure)
            {
                return(-1);
            }

            return(0);
        }
Ejemplo n.º 11
0
		private void WriteResultsToFile()
		{
			var path = System.IO.Path.Combine (Application.dataPath,
												Application.loadedLevelName + "-TestResults.xml");
			var resultWriter = new XmlResultWriter(Application.loadedLevelName, path);
			resultWriter.SaveTestResult(testToRun.ToArray());
		}
Ejemplo n.º 12
0
        private void FormatResult(NUnit2Test testElement, TestResult result)
        {
            // temp file for storing test results
            string xmlResultFile = Path.GetTempFileName();

            try {
                XmlResultWriter resultWriter = new XmlResultWriter(xmlResultFile);
                resultWriter.SaveTestResult(result);

                foreach (FormatterElement formatter in FormatterElements)
                {
                    // permanent file for storing test results
                    string outputFile = result.Name + "-results" + formatter.Extension;

                    if (formatter.Type == FormatterType.Xml)
                    {
                        if (formatter.UseFile)
                        {
                            if (formatter.OutputDirectory != null)
                            {
                                // ensure output directory exists
                                if (!formatter.OutputDirectory.Exists)
                                {
                                    formatter.OutputDirectory.Create();
                                }

                                // combine output directory and result filename
                                outputFile = Path.Combine(formatter.OutputDirectory.FullName,
                                                          Path.GetFileName(outputFile));
                            }

                            // copy the temp result file to permanent location
                            File.Copy(xmlResultFile, outputFile, true);
                        }
                        else
                        {
                            using (StreamReader reader = new StreamReader(xmlResultFile)) {
                                // strip off the xml header
                                reader.ReadLine();
                                StringBuilder builder = new StringBuilder();
                                while (reader.Peek() > -1)
                                {
                                    builder.Append(reader.ReadLine().Trim()).Append(
                                        Environment.NewLine);
                                }
                                Log(Level.Info, builder.ToString());
                            }
                        }
                    }
                    else if (formatter.Type == FormatterType.Plain)
                    {
                        TextWriter writer;
                        if (formatter.UseFile)
                        {
                            if (formatter.OutputDirectory != null)
                            {
                                // ensure output directory exists
                                if (!formatter.OutputDirectory.Exists)
                                {
                                    formatter.OutputDirectory.Create();
                                }

                                // combine output directory and result filename
                                outputFile = Path.Combine(formatter.OutputDirectory.FullName,
                                                          Path.GetFileName(outputFile));
                            }

                            writer = new StreamWriter(outputFile);
                        }
                        else
                        {
                            writer = new LogWriter(this, Level.Info, CultureInfo.InvariantCulture);
                        }
                        CreateSummaryDocument(xmlResultFile, writer, testElement);
                        writer.Close();
                    }
                }
            } catch (Exception ex) {
                throw new BuildException("Test results could not be formatted.",
                                         Location, ex);
            } finally {
                // make sure temp file with test results is removed
                File.Delete(xmlResultFile);
            }
        }
Ejemplo n.º 13
0
			public void RunFinished ()
			{
				var resultWriter = new XmlResultWriter("UnitTestResults.xml");
				resultWriter.SaveTestResult ("Unit Tests", unitTestView.testList.ToArray ());
				EditorUtility.ClearProgressBar();
			}
Ejemplo n.º 14
0
			public void RunFinished ()
			{
				var resultWriter = new XmlResultWriter(EditorApplication.currentScene,
															"UnitTestResults.xml");
				resultWriter.SaveTestResult(unitTestView.testList.ToArray());
				EditorUtility.ClearProgressBar();
			}
Ejemplo n.º 15
0
 private void WriteResultsToFile()
 {
     string path = Path.Combine(Application.dataPath, Application.loadedLevelName + "-TestResults.xml");
     Debug.Log("Saving results in " + path);
     var resultWriter = new XmlResultWriter(path);
     resultWriter.SaveTestResult(Application.loadedLevelName, testToRun.ToArray());
 }