Beispiel #1
0
        public void Report(string title, string message, ReporterTestInfo.TestStatus status, ReportElementType type)
        {
            ReportElement element = new ReportElement();

            if (null == testDetails)
            {
                Console.WriteLine("HTML reporter was not initiliazed propertly. No reports would be created.");
                return;
            }
            testDetails.AddReportElement(element);
            element.title   = title;
            element.message = message;
            element.time    = DateTime.Now.ToString("HH:mm:ss");
            element.status  = status.ToString();
            element.type    = type.ToString();

            if (type == ReportElementType.lnk || type == ReportElementType.img)
            {
                if (File.Exists(message))
                {
                    string fileName = FileWasAdded(testDetails, message);
                    if (fileName != null)
                    {
                        element.message = fileName;
                    }
                }
            }

            TestDetailsWereAdded(testDetails);
        }
Beispiel #2
0
        public void Report(string title, string message, ReporterTestInfo.TestStatus status, ReportElementType type)
        {
            ReportElement element = new ReportElement();

            if (null == testDetails)
            {
                Console.WriteLine("HTML reporter was not initiliazed propertly. No reports would be created.");
                return;
            }

            element.title   = title;
            element.message = message;
            element.time    = DateTime.Now.ToString("HH:mm:ss");
            element.status  = status.ToString();
            element.type    = type.ToString();
            testDetails.AddReportElement(element);
            if (type == ReportElementType.lnk || type == ReportElementType.img)
            {
                if (File.Exists(message))
                {
                    string fileName = FileWasAdded(testDetails, message);
                    if (fileName != null)
                    {
                        element.message = fileName;
                    }
                }
            }

            // The stopwatch is an important mechanism that helps when test is creating a large number of message in short time intervals.
            if (!stopwatch.IsRunning)
            {
                stopwatch.Start();
            }
            else
            {
                if (stopwatch.ElapsedMilliseconds <= 100)
                {
                    return;
                }
            }
            stopwatch.Restart();

            TestDetailsWereAdded(testDetails);
        }
        public void Report(string title, string message, ReporterTestInfo.TestStatus status, ReportElementType type)
        {
            ReportElement element = new ReportElement();

            if (null == testDetails)
            {
                Console.WriteLine("HTML reporter was not initiliazed propertly. No reports would be created.");
                return;
            }
            testDetails.AddReportElement(element);
            element.title   = title;
            element.message = message;
            element.time    = DateTime.Now.ToString("HH:mm:ss");
            element.status  = status.ToString();
            element.type    = type.ToString();

            if (type == ReportElementType.lnk || type == ReportElementType.img)
            {
                if (File.Exists(message))
                {
                    //This is a link to a file. Let's copy it to the report folder
                    CreateTestFolderIfNotExists();
                    try
                    {
                        string fileName        = Path.GetFileName(message);
                        string fileDestination = testFolder + @"\" + fileName;
                        System.IO.File.Copy(message, fileDestination, true);
                        //We need that the link would be to the file in the report folder
                        element.message = fileName;
                    }
                    catch (IOException e)
                    {
                        Console.WriteLine("Failed adding file to the report due to " + e.Message);
                    }
                }
            }

            TestToFile();
        }