Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            string[]         parseErrors;
            CommandArguments arguments = ArgHelper.Instance.ParseCommandArguments(args, out parseErrors);

            bool isTitlePrinted = false;

            // errors when parsing arguments
            if (parseErrors != null && parseErrors.Length > 0)
            {
                OutputWriter.WriteTitle();
                OutputWriter.WriteLines(parseErrors);
                isTitlePrinted = true;
            }

            // show help?
            if (args.Length == 0 || arguments.ShowHelp)
            {
                OutputWriter.WriteTitle();
                OutputWriter.WriteCommandUsage();
                ProgramExit.Exit(ExitCode.Success);
                return;
            }

            // show version?
            if (arguments.ShowVersion)
            {
                OutputWriter.WriteVersion();
                ProgramExit.Exit(ExitCode.Success);
                return;
            }

            if (!isTitlePrinted)
            {
                OutputWriter.WriteTitle();
            }
            Convert(arguments);
        }
Ejemplo n.º 2
0
        static void Convert(CommandArguments args)
        {
            // input
            IEnumerable <TestReportBase> testReports = ReadInput(args);

            // output - none
            if (args.OutputFormats == OutputFormats.None)
            {
                ProgramExit.Exit(ExitCode.UnknownOutputFormat, true);
                return;
            }

            // output - junit
            if ((args.OutputFormats & OutputFormats.JUnit) == OutputFormats.JUnit)
            {
                // the output JUnit path must be NOT an exist directory
                if (Directory.Exists(args.JUnitXmlFile))
                {
                    OutputWriter.WriteLine(Properties.Resources.ErrMsg_JUnit_OutputCannotDir);
                    ProgramExit.Exit(ExitCode.InvalidArgument);
                    return;
                }

                // if not an aggregation report output, then only convert for the first report
                if (!args.Aggregation)
                {
                    TestReportBase testReport = testReports.First();
                    if (testReport == null)
                    {
                        ProgramExit.Exit(ExitCode.CannotReadFile);
                        return;
                    }

                    // the output JUnit file path must be NOT same as the input file
                    FileInfo fiInput  = new FileInfo(testReport.ReportFile);
                    FileInfo fiOutput = new FileInfo(args.JUnitXmlFile);
                    if (fiInput.FullName == fiOutput.FullName)
                    {
                        OutputWriter.WriteLine(Properties.Resources.ErrMsg_JUnit_OutputSameAsInput);
                        ProgramExit.Exit(ExitCode.InvalidArgument);
                        return;
                    }

                    // convert
                    if (!JUnit.Converter.ConvertAndSave(args, testReport))
                    {
                        ProgramExit.Exit(ExitCode.GeneralError);
                    }
                    else
                    {
                        OutputWriter.WriteLine(Properties.Resources.InfoMsg_JUnit_OutputGenerated, fiOutput.FullName);
                    }
                }
                else
                {
                    // an aggregation report output
                    if (!JUnit.Converter.ConvertAndSaveAggregation(args, testReports))
                    {
                        ProgramExit.Exit(ExitCode.GeneralError);
                    }
                    else
                    {
                        FileInfo fiOutput = new FileInfo(args.JUnitXmlFile);
                        OutputWriter.WriteLine(Properties.Resources.InfoMsg_JUnit_OutputGenerated, fiOutput.FullName);
                    }
                }
            }

            // output - nunit 3
            if ((args.OutputFormats & OutputFormats.NUnit3) == OutputFormats.NUnit3)
            {
            }
        }