Пример #1
0
        private void WriteSummaryTestResult(StreamWriter writer, IEnumerable<ITestNode> testList)
        {
            Console.WriteLine();
            var totalResult = Services.Get<IFixtureResult>();
            var totalTestTimeSpan = new TimeSpan();
            foreach (ITestNode node in testList)
            {
                if (totalResult.StartTime == null)
                    totalResult.StartTime = node.TestResult.StartTime;
                totalResult.Right += node.TestResult.Right;
                totalResult.Wrong += node.TestResult.Wrong;
                totalResult.Exceptions += node.TestResult.Exceptions;
                TimeSpan timeSpanToAdd = node.TestResult.GetTimeSpan();
                totalTestTimeSpan = totalTestTimeSpan.Add(timeSpanToAdd);
            }

            totalResult.EndTime = totalResult.StartTime + totalTestTimeSpan;
            string status = "pass";
            if ((totalResult.Wrong + totalResult.Exceptions) != 0)
                status = "fail";
            writer.Write(string.Format("<div style=\"border:1px solid black;padding:5px \" class=\"{0}\">", status));
            writer.WriteLine("<h3>Summary:</h3>");
            writer.WriteLine(FitUtilityService.GetResultHeader(totalResult));

            writer.WriteLine();
            writer.WriteLine(" Total of {0} Test Case(s) run.", testList.Count());

            writer.Write("</div>");
        }
Пример #2
0
        public string GetTestDocument()
        {
            var result = new StringBuilder();

            foreach (ITestNode fixtureNode in GetTreeChildEnumerator())
            {
                var runnableDoc = fixtureNode as IRunnableDoc;
                if (runnableDoc != null)
                {
                    result.AppendLine(runnableDoc.GetTestDocument());
                    result.AppendLine("<br>");
                }
            }
            IList <string> vars = new List <string>();

            FitUtilityService.GetVariables(this, ref vars);

            foreach (string defineVar in vars)
            {
                if (!defineVar.ToLower().StartsWith("path"))
                {
                    string[] splits      = defineVar.Split('=');
                    string   searchPart  = "${" + splits[0] + "}";
                    string   replacePart = splits[1];
                    result.Replace(searchPart, replacePart);
                }
            }
            return(result.ToString());
        }
Пример #3
0
 private void GenerateHtmlTestReport(ITestCase testCase)
 {
     string fileLink = GetOutputFile(testCase);
     string status = (testCase.TestResult.Pass) ? "pass" : "fail";
     string parentPath = string.Empty;
     TreeChildEnumerator.FindParentPath(testCase, ref parentPath);
     parentPath = parentPath.Substring(parentPath.IndexOf('\\') + 1);
     string testReportName = _runningNumber + ". " + testCase.Name;
     _testFileLinks.Add(
         string.Format("<a class=\"{2}\" href=\"{0}\">{1}</a> <span style=\"padding-left:3px\">( {3} )</span>",
                       Path.GetFileName(fileLink), testReportName,
                       status, parentPath));
     using (var writer = new StreamWriter(fileLink))
     {
         FitUtilityService.WriteHtmlResult(testCase, writer);
     }
 }
Пример #4
0
        private void GenerateIndexFile()
        {
            using (var writer = new StreamWriter(OutputDir + "\\index.html"))
            {
                var sb = new StringBuilder();
                WriteSummaryTestResult(writer, _testList);
                foreach (string aLink in _testFileLinks)
                {
                    sb.Append("<li>");
                    sb.Append(aLink);
                    sb.Append("</li>");
                }

                string bodyText = sb.ToString();
                writer.Write(FitUtilityService.GetHtmlTestResultBody("Test Result", FitUtilityService.GetSomeCSS(),
                                                                     _runPath, bodyText));
            }
        }