static void Main(string[] args)
        {
            if (!Directory.Exists(@".\Reports"))
            {
                Directory.CreateDirectory(@".\Reports");
            }
            File.Copy(resultFileName, @".\Reports\TestResult.xml", true);

            double totalTestcases;
            double totalPassed;
            double totalFailed;
            double totalError;
            XmlDataDocument xmldoc = new XmlDataDocument();
            XmlNodeList xmlResultsnode;
            errors = new List<ErrorItem>();
            sucess = new List<SuccessItem>();
            try
            {
                //Analize test results file
                FileStream fstream = new FileStream(resultFileName, FileMode.Open, FileAccess.Read);
                try
                {
                    XmlDocument xmlDoc = new XmlDocument();
                    xmlDoc.Load(fstream);
                    LoadTestResults(xmlDoc.DocumentElement);
                }
                finally
                {
                    fstream.Close();
                }
            }
            catch (Exception ex)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("Error occur: ");
                Console.ForegroundColor = ConsoleColor.Magenta;
                Console.WriteLine(ex.Message);
                Console.Beep();
                Console.ForegroundColor = ConsoleColor.Gray;
                Console.WriteLine("");
                Console.WriteLine("Press any key to continue...");
                Console.ReadKey(true);
                return;
            }
            CreatePlayBack playback = new CreatePlayBack(Directory.GetCurrentDirectory() + @"\Reports\");
            playback.CreateReports();
            FileStream fs = new FileStream(resultFileName, FileMode.Open, FileAccess.Read);
            xmldoc.Load(fs);
            xmlResultsnode = xmldoc.SelectNodes("//test-results[contains(@ignored,'0')]");
            totalTestcases = Convert.ToDouble(xmlResultsnode[0].Attributes["total"].Value);
            totalFailed = Convert.ToDouble(xmlResultsnode[0].Attributes["failures"].Value);
            totalError = Convert.ToDouble(xmlResultsnode[0].Attributes["errors"].Value);
            totalPassed = totalTestcases - totalFailed - totalError;
            totalFailed = totalFailed + totalError;

            StringBuilder sb = new StringBuilder();
            sb.AppendLine("<Html>");
            CreateHtmlHeader(sb);
            sb.AppendLine("<body background=\"./img/background.jpg\">");
            CreateHeadline(sb);
            CreateSummary(sb, "TCD Automation", totalTestcases, totalPassed, totalFailed);
            CreateBody(sb, sucess);
            CreateChartScript(sb, totalFailed, totalPassed);
            EndHtml(sb);

            FileStream f = new FileStream(htmlPath, FileMode.Create, FileAccess.Write);
            using (StreamWriter s = new StreamWriter(f))
                s.WriteLine(sb.ToString());
            if (File.Exists(htmlPath))
            {
                Console.WriteLine("Report Generated");
            }
        }
Exemple #2
0
 static void Main(string[] args)
 {
     CreatePlayBack playback = new CreatePlayBack(Directory.GetCurrentDirectory() + @"\ReportLog\");
     playback.CreateReports();
 }