Exemple #1
0
        private static XElement TestElement(CaseResult caseResult)
        {
            var name = caseResult.Name;
            var index = name.IndexOf("(");
            if (index != -1)
                name = name.Substring(0, index);
            index = name.LastIndexOf(".");
            var type = name.Substring(0, index);
            var method = name.Substring(index + 1);

            var test = new XElement("test",
                new XAttribute("name", caseResult.Name),
                new XAttribute("type", type),
                new XAttribute("method", method),
                new XAttribute("result", caseResult.Status == CaseStatus.Failed
                    ? "fail"
                    : caseResult.Status == CaseStatus.Passed
                        ? "pass"
                        : "skip"));

            if (caseResult.Status == CaseStatus.Skipped)
                test.Add(new XElement("reason", new XElement("message", caseResult.SkipReason ?? string.Empty)));

            if (caseResult.Status != CaseStatus.Skipped)
                test.Add(new XAttribute("time", GetTime(caseResult.Duration)));

            if (caseResult.Status == CaseStatus.Failed)
                test.Add(FailureElement(caseResult));

            return test;
        }
Exemple #2
0
        static XElement TestSuiteElement(CaseResult caseResult)
        {
            var @case = new XElement("test-case");

            @case.Add(new XAttribute("name", caseResult.Name));

            @case.Add(new XAttribute("executed", caseResult.Status != CaseStatus.Skipped));
            @case.Add(new XAttribute("success", caseResult.Status != CaseStatus.Failed));

            if (caseResult.Status != CaseStatus.Skipped)
                @case.Add(new XAttribute("time", caseResult.Duration.TotalSeconds.ToString("0.000")));

            if (caseResult.Status == CaseStatus.Failed)
            {
                @case.Add(
                    new XElement("failure",
                        new XElement("message", new XCData(caseResult.Message)),
                        new XElement("stack-trace", new XCData(caseResult.StackTrace))));
            }

            if (caseResult.Status == CaseStatus.Skipped)
            {
                @case.Add(
                    new XElement("reason",
                        new XElement("message", new XCData(caseResult.SkipReason ?? string.Empty))));
            }

            return @case;
        }
Exemple #3
0
 private static XElement FailureElement(CaseResult caseResult)
 {
     return new XElement("failure",
         new XAttribute("exception-type", caseResult.ExceptionType),
         new XElement("message", caseResult.Message),
         new XElement("stack-trace", caseResult.StackTrace));
 }
Exemple #4
0
        static XElement Case(CaseResult caseResult)
        {
            var @case = new XElement("test-case",
                new XAttribute("name", caseResult.Name),
                new XAttribute("executed", caseResult.Status != CaseStatus.Skipped),
                new XAttribute("success", caseResult.Status != CaseStatus.Failed));

            if (caseResult.Status != CaseStatus.Skipped)
                @case.Add(new XAttribute("time", Seconds(caseResult.Duration)));

            if (caseResult.Status == CaseStatus.Skipped && caseResult.SkipReason != null)
                @case.Add(new XElement("reason", new XElement("message", new XCData(caseResult.SkipReason))));

            if (caseResult.Status == CaseStatus.Failed)
            {
                @case.Add(
                    new XElement("failure",
                        new XElement("message", new XCData(caseResult.ExceptionSummary.Message)),
                        new XElement("stack-trace", new XCData(caseResult.ExceptionSummary.StackTrace))));
            }

            return @case;
        }
Exemple #5
0
        private static XElement Case(CaseResult caseResult)
        {
            var nameWithoutParameters = caseResult.Name;
            var indexOfOpenParen = nameWithoutParameters.IndexOf("(");
            if (indexOfOpenParen != -1)
                nameWithoutParameters = nameWithoutParameters.Substring(0, indexOfOpenParen);

            var indexOfLastDot = nameWithoutParameters.LastIndexOf(".");
            var type = nameWithoutParameters.Substring(0, indexOfLastDot);
            var method = nameWithoutParameters.Substring(indexOfLastDot + 1);

            var @case = new XElement("test",
                new XAttribute("name", caseResult.Name),
                new XAttribute("type", type),
                new XAttribute("method", method),
                new XAttribute("result",
                    caseResult.Status == CaseStatus.Failed
                        ? "Fail"
                        : caseResult.Status == CaseStatus.Passed
                            ? "Pass"
                            : "Skip"));

            if (caseResult.Status != CaseStatus.Skipped)
                @case.Add(new XAttribute("time", Seconds(caseResult.Duration)));

            if (caseResult.Status == CaseStatus.Skipped && caseResult.SkipReason != null)
                @case.Add(new XElement("reason", new XElement("message", new XCData(caseResult.SkipReason))));

            if (caseResult.Status == CaseStatus.Failed)
                @case.Add(
                    new XElement("failure",
                        new XAttribute("exception-type", caseResult.ExceptionSummary.Type),
                        new XElement("message", new XCData(caseResult.ExceptionSummary.Message)),
                        new XElement("stack-trace", new XCData(caseResult.ExceptionSummary.StackTrace))));

            return @case;
        }
Exemple #6
0
 public void Add(CaseResult caseResult)
 {
     caseResults.Add(caseResult);
 }
Exemple #7
0
 public void Add(CaseResult caseResult)
 {
     caseResults.Add(caseResult);
 }