/// <summary>
        /// Write the result of a test run according to a spec.
        /// </summary>
        /// <param name="result">The test result</param>
        /// <param name="spec">An output specification</param>
        public void WriteResultFile(ITestResult result, OutputSpecification spec)
        {
            string outputPath = Path.Combine(_workDirectory, spec.OutputPath);
            OutputWriter outputWriter = null;

            switch (spec.Format)
            {
                case "nunit3":
                    outputWriter = new NUnit3XmlOutputWriter();
                    break;

                case "nunit2":
                    outputWriter = new NUnit2XmlOutputWriter();
                    break;

                //case "user":
                //    Uri uri = new Uri(Assembly.GetExecutingAssembly().CodeBase);
                //    string dir = Path.GetDirectoryName(uri.LocalPath);
                //    outputWriter = new XmlTransformOutputWriter(Path.Combine(dir, spec.Transform));
                //    break;

                default:
                    throw new ArgumentException(
                        string.Format("Invalid XML output format '{0}'", spec.Format),
                        "spec");
            }

            outputWriter.WriteResultFile(result, outputPath);
            Console.WriteLine("Results ({0}) saved as {1}", spec.Format, outputPath);
        }
Exemple #2
0
        /// <summary>
        /// Write out the result of exploring the tests
        /// </summary>
        /// <param name="test">The top-level test</param>
        /// <param name="spec">An OutputSpecification</param>
        public void WriteTestFile(ITest test, OutputSpecification spec)
        {
            string       outputPath   = Path.Combine(_workDirectory, spec.OutputPath);
            OutputWriter outputWriter = null;

            switch (spec.Format)
            {
            case "nunit3":
                outputWriter = new NUnit3XmlOutputWriter();
                break;

            case "cases":
                outputWriter = new TestCaseOutputWriter();
                break;

            //case "user":
            //    Uri uri = new Uri(Assembly.GetExecutingAssembly().CodeBase);
            //    string dir = Path.GetDirectoryName(uri.LocalPath);
            //    outputWriter = new XmlTransformOutputWriter(Path.Combine(dir, spec.Transform));
            //    break;

            default:
                throw new ArgumentException(
                          string.Format("Invalid XML output format '{0}'", spec.Format),
                          "spec");
            }

            outputWriter.WriteTestFile(test, outputPath);
            Console.WriteLine("Tests ({0}) saved as {1}", spec.Format, outputPath);
        }