void OnChildSessionFinished(XUnitExecutionSession childSession) { result.Add(childSession.result); // end session if the last child session finished if (++childSessionsFinished == childSessions.Count) { End(); } }
UnitTestResult ReportXmlResult(IRemoteEventListener listener, XElement elem, string testPrefix, bool macunitStyle) { UnitTestResult result = new UnitTestResult(); var time = (string)elem.Attribute("time"); if (time != null) { result.Time = TimeSpan.FromSeconds(double.Parse(time, CultureInfo.InvariantCulture)); } result.TestDate = DateTime.Now; var reason = elem.Element("reason"); if (reason != null) { result.Message = (string)reason; } var failure = elem.Element("failure"); if (failure != null) { var msg = failure.Element("message"); if (msg != null) { result.Message = (string)msg; } var stack = failure.Element("stack-trace"); if (stack != null) { result.StackTrace = (string)stack; } } switch ((string)elem.Attribute("result")) { case "Error": case "Failure": result.Status = ResultStatus.Failure; break; case "Success": result.Status = ResultStatus.Success; break; case "Ignored": result.Status = ResultStatus.Ignored; break; default: result.Status = ResultStatus.Inconclusive; break; } if (elem.Name == "test-suite") { // nunitlite does not emit <test-suite type="Namespace" elements so we need to fake // them by deconstructing the full type name and emitting the suite started events manually var names = new List <string> (); if (!macunitStyle || (string)elem.Attribute("type") == "Assembly") { names.Add("<root>"); } else { names.AddRange(elem.Attribute("name").Value.Split('.')); } for (int i = 0; i < names.Count; i++) { listener.SuiteStarted(testPrefix + string.Join(".", names.Take(i + 1))); } var name = (string)elem.Attribute("type") == "Assembly" ? "<root>" : (string)elem.Attribute("name"); var cts = elem.Element("results"); if (cts != null) { foreach (var ct in cts.Elements()) { var r = ReportXmlResult(listener, ct, name != "<root>" ? testPrefix + name + "." : "", macunitStyle); result.Add(r); } } for (int i = 0; i < names.Count; i++) { listener.SuiteFinished(testPrefix + string.Join(".", names.Take(i + 1)), result); } } else { string name = (string)elem.Attribute("name"); switch (result.Status) { case ResultStatus.Success: result.Passed++; break; case ResultStatus.Failure: result.Failures++; break; case ResultStatus.Ignored: result.Ignored++; break; case ResultStatus.Inconclusive: result.Inconclusive++; break; } listener.TestStarted(name); listener.TestFinished(name, result); } return(result); }
UnitTestResult ReportXmlResult (IRemoteEventListener listener, XElement elem, string testPrefix, bool macunitStyle) { UnitTestResult result = new UnitTestResult (); var time = (string)elem.Attribute ("time"); if (time != null) result.Time = TimeSpan.FromSeconds (double.Parse (time, CultureInfo.InvariantCulture)); result.TestDate = DateTime.Now; var reason = elem.Element ("reason"); if (reason != null) result.Message = (string) reason; var failure = elem.Element ("failure"); if (failure != null) { var msg = failure.Element ("message"); if (msg != null) result.Message = (string)msg; var stack = failure.Element ("stack-trace"); if (stack != null) result.StackTrace = (string)stack; } switch ((string)elem.Attribute ("result")) { case "Error": case "Failure": result.Status = ResultStatus.Failure; break; case "Success": result.Status = ResultStatus.Success; break; case "Ignored": result.Status = ResultStatus.Ignored; break; default: result.Status = ResultStatus.Inconclusive; break; } if (elem.Name == "test-suite") { // nunitlite does not emit <test-suite type="Namespace" elements so we need to fake // them by deconstructing the full type name and emitting the suite started events manually var names = new List<string> (); if (!macunitStyle || (string)elem.Attribute ("type") == "Assembly") names.Add ("<root>"); else names.AddRange (elem.Attribute ("name").Value.Split ('.')); for (int i = 0; i < names.Count; i ++) listener.SuiteStarted (testPrefix + string.Join (".", names.Take (i + 1))); var name = (string)elem.Attribute ("type") == "Assembly" ? "<root>" : (string) elem.Attribute ("name"); var cts = elem.Element ("results"); if (cts != null) { foreach (var ct in cts.Elements ()) { var r = ReportXmlResult (listener, ct, name != "<root>" ? testPrefix + name + "." : "", macunitStyle); result.Add (r); } } for (int i = 0; i < names.Count; i ++) listener.SuiteFinished (testPrefix + string.Join (".", names.Take (i + 1)), result); } else { string name = (string)elem.Attribute ("name"); switch (result.Status) { case ResultStatus.Success: result.Passed++; break; case ResultStatus.Failure: result.Failures++; break; case ResultStatus.Ignored: result.Ignored++; break; case ResultStatus.Inconclusive: result.Inconclusive++; break; } listener.TestStarted (name); listener.TestFinished (name, result); } return result; }