Example #1
0
        /// <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, IDictionary runSettings, TestFilter filter)
        {
            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, runSettings, filter);
            Console.WriteLine("Results ({0}) saved as {1}", spec.Format, outputPath);
        }
Example #2
0
        private void ResolveOutputSpecification(string value, IList <OutputSpecification> outputSpecifications)
        {
            if (value == null)
            {
                return;
            }

            OutputSpecification spec;

            try
            {
                spec = new OutputSpecification(value, CURRENT_DIRECTORY_ON_ENTRY);
            }
            catch (ArgumentException e)
            {
                ErrorMessages.Add(e.Message);
                return;
            }

            if (spec.Transform != null)
            {
                if (!_fileSystem.FileExists(spec.Transform))
                {
                    ErrorMessages.Add($"Transform {spec.Transform} could not be found.");
                    return;
                }
            }

            outputSpecifications.Add(spec);
        }
Example #3
0
        private void ResolveOutputSpecification(string value, IList <OutputSpecification> outputSpecifications)
        {
            if (value == null)
            {
                return;
            }

            try
            {
                var spec = new OutputSpecification(value);
                outputSpecifications.Add(spec);
            }
            catch (ArgumentException e)
            {
                ErrorMessages.Add(e.Message);
            }
        }