public string GetRunStateFromResultNunitXml(ITestResultAdaptor result) { var doc = new XmlDocument(); doc.LoadXml(result.ToXml().OuterXml); return(doc.FirstChild.Attributes["runstate"].Value); }
void WriteResultsToXml(ITestResultAdaptor result, XmlWriter xmlWriter) { // XML format as specified at https://github.com/nunit/docs/wiki/Test-Result-XML-Format var testRunNode = new TNode(k_TestRunNode); testRunNode.AddAttribute(k_Id, "2"); testRunNode.AddAttribute(k_Testcasecount, (result.PassCount + result.FailCount + result.SkipCount + result.InconclusiveCount).ToString()); testRunNode.AddAttribute(k_Result, result.ResultState.ToString()); testRunNode.AddAttribute(k_Total, (result.PassCount + result.FailCount + result.SkipCount + result.InconclusiveCount).ToString()); testRunNode.AddAttribute(k_Passed, result.PassCount.ToString()); testRunNode.AddAttribute(k_Failed, result.FailCount.ToString()); testRunNode.AddAttribute(k_Inconclusive, result.InconclusiveCount.ToString()); testRunNode.AddAttribute(k_Skipped, result.SkipCount.ToString()); testRunNode.AddAttribute(k_Asserts, result.AssertCount.ToString()); testRunNode.AddAttribute(k_EngineVersion, k_nUnitVersion); testRunNode.AddAttribute(k_ClrVersion, Environment.Version.ToString()); testRunNode.AddAttribute(k_StartTime, result.StartTime.ToString(k_TimeFormat)); testRunNode.AddAttribute(k_EndTime, result.EndTime.ToString(k_TimeFormat)); testRunNode.AddAttribute(k_Duration, result.Duration.ToString()); var resultNode = result.ToXml(); testRunNode.ChildNodes.Add(resultNode); testRunNode.WriteTo(xmlWriter); }