/// <summary> /// Creates a <see cref="TestAssembly"/> which is a complete object model over /// the tests inside of instance of <see cref="IExecutorWrapper"/>. /// </summary> /// <param name="executorWrapper">The executor wrapper</param> /// <returns>The fully populated object model</returns> public static TestAssembly Build(IExecutorWrapper executorWrapper) { Guard.ArgumentNotNull("executorWrapper", executorWrapper); List<TestClass> classes = new List<TestClass>(); foreach (XmlNode classNode in executorWrapper.EnumerateTests().SelectNodes("//class")) { List<TestMethod> methods = new List<TestMethod>(); string typeName = classNode.Attributes["name"].Value; foreach (XmlNode testNode in classNode.SelectNodes("method")) { string methodName = testNode.Attributes["method"].Value; string displayName = null; string skipReason = null; if (testNode.Attributes["name"] != null) displayName = testNode.Attributes["name"].Value; if (testNode.Attributes["skip"] != null) skipReason = testNode.Attributes["skip"].Value; var traits = new MultiValueDictionary<string, string>(); foreach (XmlNode traitNode in testNode.SelectNodes("traits/trait")) traits.AddValue(traitNode.Attributes["name"].Value, traitNode.Attributes["value"].Value); TestMethod testMethod = new TestMethod(methodName, displayName ?? typeName + "." + methodName, traits); methods.Add(testMethod); if (!String.IsNullOrEmpty(skipReason)) testMethod.RunResults.Add(new TestSkippedResult(testMethod.DisplayName, skipReason)); } classes.Add(new TestClass(typeName, methods)); } return new TestAssembly(executorWrapper, classes); }
public bool TestStart(TestMethod testMethod) { return true; }
public bool TestFinished(TestMethod testMethod) { return true; }
private void DoProcessTest(TestMethod testMethod) { var lastRunResult = testMethod.RunResults.Last(); if (lastRunResult is TestPassedResult) TestPassed(lastRunResult as TestPassedResult); else if (lastRunResult is TestFailedResult) TestFailed(lastRunResult as TestFailedResult); else TestSkipped(lastRunResult as TestSkippedResult); }
public bool TestStart(TestMethod testMethod) { return !_isCancelRequested; }
public bool TestFinished(TestMethod testMethod) { Application.Current.Dispatcher.BeginInvoke((Action)(() => DoProcessTest(testMethod))); return !_isCancelRequested; }
public bool TestStart(TestMethod testMethod) { Console.WriteLine("{0,4}: {1}", ++index, testMethod.DisplayName); return true; }
public virtual bool TestFinished(TestMethod testMethod) { var result = testMethod.RunResults.Last(); var passedResult = result as TestPassedResult; if (passedResult != null && _displaySuccess) { TestPassed(passedResult); } else { var failedResult = result as TestFailedResult; if (failedResult != null) { TestFailed(testMethod, failedResult); } else { var skippedResult = result as TestSkippedResult; if (skippedResult != null) { TestSkipped(testMethod, skippedResult); } } } Console.WriteLine("Tests complete: {0} of {1}".DarkGrey(), ++TotalTests, _testMethodCount); return true; }
protected virtual void TestSkipped(TestMethod testMethod, TestSkippedResult result) { Console.WriteLine("[SKIPPED] : {0} ".Yellow(), result.DisplayName); Console.WriteLine(Indent(result.Reason)); }
protected virtual void TestFailed(TestMethod testMethod, TestFailedResult result) { Console.WriteLine("[FAILED] : {0} ".Red(), result.DisplayName); Console.WriteLine(Indent(result.ExceptionMessage)); if (result.ExceptionStackTrace == null || !_displayFailureStack) { return; } Console.WriteLine(Indent("Stack Trace:").DarkGrey()); Console.WriteLine(Indent(StackFrameTransformer.TransformStack(result.ExceptionStackTrace)).DarkGrey()); }
public virtual bool TestStart(TestMethod testMethod) { return true; }
public bool TestFinished(TestMethod testMethod) { Console.WriteLine("{0} :: {1}\n", testMethod.RunStatus, testMethod.MethodName); return true; }
public bool TestStart(TestMethod testMethod) { return innerCallback.TestStart(testMethod); }
public bool TestFinished(TestMethod testMethod) { if (testMethod == null) return false; ++Total; var lastRunResult = testMethod.RunResults[testMethod.RunResults.Count - 1]; if (lastRunResult is TestFailedResult) ++Failed; if (lastRunResult is TestSkippedResult) ++Skipped; Time += lastRunResult.Duration; return innerCallback.TestFinished(testMethod); }
public bool TestStart(TestMethod testMethod) { return(innerCallback.TestStart(testMethod)); }