예제 #1
0
        public void FromSpecContainers(SpecificationStatus[] specs)
        {
            _filewriter.Open(_location.OutputDirectory + Path.DirectorySeparatorChar + "spec-output.xml");
            var contexts = getall(specs);
            _filewriter.WriteLine("<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"no\"?>");
            int total = TotalSpecs(contexts, x => true);
            int failure = TotalSpecs(contexts,x=>x.Status == RuleStatus.Failed || x.Status== RuleStatus.Error);
            int pending = TotalSpecs(contexts, x => x.Status == RuleStatus.Pending);
            _filewriter.WriteLine(String.Format("<test-results name=\"SpecMaker rules\" total=\"{0}\" failures=\"{1}\" not-run=\"{2}\">", total, failure, pending));
            _filewriter.WriteLine("<results>");
            foreach (var spec in contexts)
            {

                _filewriter.WriteLine(String.Format( "<test-suite name=\"{0} {1}\" success=\"True\"  asserts=\"0\">", spec.SpecObject, spec.Context));
                _filewriter.WriteLine("<results>");
                foreach (var result in spec.Rules)
                {
                    string issuccess = "True";
                    if (result.Status != RuleStatus.Passed)
                        issuccess = "False";
                    _filewriter.WriteLine(String.Format("<test-case name=\"{0}\" executed=\"True\" success=\"{1}\" time=\"0.000\" asserts=\"1\" />",result.Description, issuccess));
                }

                _filewriter.WriteLine("</results>");
                _filewriter.WriteLine("</test-suite>");
            }
            _filewriter.WriteLine("</results>");
            _filewriter.WriteLine("</test-results>");
               _filewriter.Close();
        }
예제 #2
0
 private IEnumerable<ContextResult> getall(SpecificationStatus[] spec)
 {
     List<ContextResult> results = new List<ContextResult>();
     foreach (var statuse in spec)
     {
         results.AddRange(statuse.Results);
     }
     return results;
 }
예제 #3
0
        public void FromSpecContainers(SpecificationStatus[] contexts)
        {
            _wrapper.ForegroundColor = ConsoleColor.DarkYellow;
            _wrapper.WriteLine("\n");
            _wrapper.WriteLine("Specifications Below");
            _wrapper.WriteLine("-------------------------------------");
            _wrapper.WriteLine("\n");
            _wrapper.ResetColor();
            var failedrules = new List<FailedRule>();
            foreach (var specstatus in contexts)
            {

                _wrapper.WriteLine(specstatus.ObjectUnderDescription);
                foreach (var spec in specstatus.Results)
                {
                      _wrapper.WriteLine("\t"+spec.Context);
                foreach (var item in spec.Rules)
                {
                    var currentcolor = _wrapper.ForegroundColor;
                    _wrapper.Write("\t - It should " + item.Description + " - " );
                    DisplayItem(item.Status, currentcolor);
                    if(!string.IsNullOrEmpty(item.RuleMessage.Trim()))
                    {

                        _wrapper.WriteLine("\t Stack Trace:");
                        _wrapper.WriteLine("\t --------------------------------------");

                        _wrapper.WriteLine("\t" + item.RuleMessage);
                        _wrapper.WriteLine("\t -------------------------------------");
                        _wrapper.WriteLine("\n");
                    }
                    if (FailedStatus(item.Status))
                        failedrules.Add(new FailedRule()
                                            {
                                                Context = spec.Context,
                                                Description = item.Description,
                                                ErrorMessage = item.RuleMessage,
                                                ObjectDescribed = specstatus.ObjectUnderDescription,
                                                Status = item.Status.DisplayName
                                            });
                }
                }

            }
            var failedspecs = GetSpecTypeCount(contexts, RuleStatus.Failed);
            var errorspecs = GetSpecTypeCount(contexts, RuleStatus.Error);
            var pending = GetSpecTypeCount(contexts, RuleStatus.Pending);
            var passed = GetSpecTypeCount(contexts, RuleStatus.Passed);
            _wrapper.WriteLine("\n");
            _wrapper.ForegroundColor = ConsoleColor.DarkYellow;
            _wrapper.WriteLine("Summmary Statistics");
            _wrapper.WriteLine("-------------------------------------");
            _wrapper.ResetColor();

            _wrapper.WriteLine(String.Format("Passed: {0}, Failed: {1}, Pending {2}",passed, failedspecs+errorspecs, pending ));
            var objects = contexts.Count();
            var context = contexts.Sum(x=>x.Results.Count());
            var total = pending + failedspecs + errorspecs + passed;
            _wrapper.WriteLine(String.Format("Objects Described: {0}, Contexts: {1}, Total Rules: {2}", objects,context , total));
            if((failedrules.Count)>0)
            {
                _wrapper.WriteLine("\n");
                _wrapper.ForegroundColor = ConsoleColor.Red;
                _wrapper.WriteLine("Failed Rules Below:");
                _wrapper.WriteLine("-------------------------------------");
                _wrapper.ResetColor();
                _wrapper.WriteLine("\n");
                int count = 0;
                foreach (var rule in failedrules)
                {
                    count += 1;
                    var titlemessage = String.Format("{0}) Spec: {1}, Context: {2}, Rule: {3}, Status: {4}", count,
                                                     rule.ObjectDescribed, rule.Context, rule.Description, rule.Status);
                    _wrapper.WriteLine(titlemessage);
                    _wrapper.WriteLine(String.Format("\t- Error Message: {0}", rule.ErrorMessage));
                }

            }
        }
예제 #4
0
        public void FromSpecContainers(SpecificationStatus[] specStatus)
        {
            _iowriter.Open(_location.OutputDirectory+"\\"+"spec-report.html");
            _iowriter.WriteLine("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">"+
            "<html xmlns=\"http://www.w3.org/1999/xhtml\">"+
            "<head>"+
            "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />"+
            "<title>Specifications</title>"+
            "<style type=\"text/css\">" +
            @"
            body  { font: 100% Verdana, Arial, Helvetica, sans-serif; font-size: 11px;}
            .TableSpecSummary { width:650px; font-size: 11px; font-family:Verdana, Arial, Helvetica, sans-serif; color: #333333; border: 1px solid #DDDDDD; border-collapse: collapse;}
            .TableSpecSummary td { border-bottom: 1px solid #DDDDDD; border-right: 1px solid #DDDDDD; }
            .TableSpecSummary th { font-weight: bold; font-size:11px; font-family: Arial,Verdana, Helvetica, sans-serif; text-align:left; height: 20px;  border-bottom: 1px solid #DDDDDD; border-right: 1px solid #DDDDDD; background-color: #EEEEEE; }

            .TableSpecDetails { width:650px; font-size: 11px; font-family:Verdana, Arial, Helvetica, sans-serif; color: #333333; border: 1px solid #DDDDDD; border-collapse: collapse;}
            .TableSpecDetails th { font-weight: bold; font-size:11px; font-family: Arial,Verdana, Helvetica, sans-serif; text-align:left; height: 20px; background-color: #DDDDDD; }
            .TableSpecDetails .odd { background-color:#EEEEEE; }
            .TableSpecDetails .pending {color:#3399CC; }
            .TableSpecDetails .failed {color:#CC0000; }
            .TableSpecDetails .success {color:#009900; }
            .contextrow {border: 1px solid #DDDDDD;}
            </style>
            </head>

            <body>
            <h2>Spec Results</h2>" +
            "<table id=\"TableSpecSummary\" cellpadding=\"2\" cellspacing=\"2\">"+
              "<tr>"+
            "<td colspan=\"5\" height=\"20\"><strong>RESULT SUMMARY</strong></td>"+

              @"</tr>
              <tr>
            <th>Assembly:</th>"+
            "<th align=\"center\">Total Test:</th>"+
            "<th align=\"center\">Failed:</th>"+
            "<th align=\"center\">Pending:</th>"+
            "<th align=\"center\">Total Time:</th>"+
            @"
              </tr>
              <tr>"
            +"<td>not in yet</td>"
               + " <td>" + Total (specStatus)+ "</td>"
               + " <td>" + Failed(specStatus) + "</td>"
               +" <td>"+TotalPending(specStatus)+"</td>"
               +" <td>Feature not added</td>"

             +" </tr>"
            +"</table>"

              );

            foreach (var status in specStatus)
            {

                _iowriter.WriteLine(
                    "<br /><hr noshade=\"noshade\" width=\"670\" color=\"#DDDDDD\" align=\"left\" /> <br />" +
                    "<table class=\"TableSpecDetails\" cellpadding=\"2\" cellspacing=\"2\">" +
                    "<tr>" +
                    " <td colspan=\"3\" height=\"20\"><strong>SPECS FOR - " + HttpUtility.HtmlEncode(status.ObjectUnderDescription) +
                    "</strong></td>" +
                    "</tr>");
                foreach (var result in status.Results)
                {
                    _iowriter.WriteLine(
                        String.Format(
                            @"<tr>
            <td colspan='3'  class='contextrow'><strong> Context: {0}</strong></td>
              </tr>
              <tr>
            <th>Rules</th>
            <th width='100'>Result</th>
            <th width='100'>Message</th>
              </tr>
            <br>",
                            result.Context));

                    foreach (var rules in result.Rules)
                    {
                        _iowriter.WriteLine(String.Format(@"<tr>
                        <td>should {0}</td>
                        <td>{1}</span></td>"+
                        "<td>{2}</td>"+
                        "</tr>",HttpUtility.HtmlEncode(rules.Description),BuildResult(rules.Status),
                             HttpUtility.HtmlEncode( rules.RuleMessage)));

                    }

                }
                _iowriter.WriteLine("</table>");
            }
            _iowriter.WriteLine("<p> </p></div></body></html>");

            _iowriter.Close();
        }