當前位置: 首頁>>代碼示例>>C#>>正文


C# UnitTestResult.Add方法代碼示例

本文整理匯總了C#中MonoDevelop.NUnit.UnitTestResult.Add方法的典型用法代碼示例。如果您正苦於以下問題:C# UnitTestResult.Add方法的具體用法?C# UnitTestResult.Add怎麽用?C# UnitTestResult.Add使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在MonoDevelop.NUnit.UnitTestResult的用法示例。


在下文中一共展示了UnitTestResult.Add方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: OnRun

		protected override UnitTestResult OnRun (TestContext testContext)
		{
			UnitTestResult tres = new UnitTestResult ();
			OnBeginTest (testContext);
			
			try {
				foreach (UnitTest t in Tests) {
					if (t.IsExplicit)
						continue;
					UnitTestResult res;
					try {
						res = OnRunChildTest (t, testContext);
						if (testContext.Monitor.IsCancelRequested)
							break;
					} catch (Exception ex) {
						res = UnitTestResult.CreateFailure (ex);
					}
					tres.Add (res);
				}
			} finally {
				OnEndTest (testContext);
			}
			return tres;
		}
開發者ID:Kalnor,項目名稱:monodevelop,代碼行數:24,代碼來源:UnitTestGroup.cs

示例2: ReportXmlResult

		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;
		}
開發者ID:riverans,項目名稱:monodevelop,代碼行數:82,代碼來源:NUnitAssemblyTestSuite.cs

示例3: ReportXmlResult

		UnitTestResult ReportXmlResult (IRemoteEventListener listener, XElement elem, string testPrefix)
		{
			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") {
				var name = (string)elem.Attribute ("type") == "Assembly" ? "<root>" : (string) elem.Attribute ("name");
				listener.SuiteStarted (testPrefix + name);
				var cts = elem.Element ("results");
				if (cts != null) {
					foreach (var ct in cts.Elements ()) {
						var r = ReportXmlResult (listener, ct, name != "<root>" ? testPrefix + name + "." : "");
						result.Add (r);
					}
				}
				listener.SuiteFinished (testPrefix + name, 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;
		}
開發者ID:halleyxu,項目名稱:monodevelop,代碼行數:71,代碼來源:NUnitAssemblyTestSuite.cs


注:本文中的MonoDevelop.NUnit.UnitTestResult.Add方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。