Beispiel #1
0
 public void SetUp()
 {
     _testResults = new XmlDocument();
     _testResults.LoadXml(_testOutput);
     _testResult = new TestResult();
     _sut        = new NunitParser();
 }
Beispiel #2
0
        static void Main(string[] args)
        {
            CheckConnection();

            if (args.Length == 1)
            {
                if (args[0] == "delete")
                {
                    DeleteTestRuns();
                }
                // If argument is a nunit xml-file -> parse and save results
                // ReSharper disable once PossibleNullReferenceException
                if (Path.GetExtension(args[0]).ToLower().Contains("xml"))
                {
                    var filename = args[0];
                    var testRun  = NunitParser.Parse(filename);
                    SaveTestRun(testRun);
                }

                // If argument is a folder
                // if the folder contains nunit xml-files -> parse and save results
                if (Directory.Exists(args[0]))
                {
                    try
                    {
                        var folderContainedXmlFiles = false;
                        var files = Directory.GetFiles(args[0]);

                        foreach (var file in files)
                        {
                            if (Path.GetExtension(file).ToLower().Contains("xml"))
                            {
                                var testRun = NunitParser.Parse(file);
                                SaveTestRun(testRun);
                                folderContainedXmlFiles = true;
                            }
                        }

                        if (!folderContainedXmlFiles)
                        {
                            Console.ForegroundColor = ConsoleColor.Red;
                            Console.WriteLine("[Error] Folder does not contain any test results.");
                            Console.ForegroundColor = ConsoleColor.White;
                            WriteUsageInfo();
                        }
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e);
                        throw;
                    }
                }
            }

            else
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("[Error] Incorrect number of arguments.\n");
                Console.ForegroundColor = ConsoleColor.White;
                WriteUsageInfo();
            }

            Console.WriteLine("End program");
            Console.ReadLine();
        }