protected internal static ITestRunner <TTestMethod> GetTestRunner <TTestMethod>(Assembly assembly, ILogger logger) where TTestMethod : TestMethod { ITestRunner <TTestMethod> runner = TestRunner <TTestMethod> .Create(assembly, logger); if (Arguments != null && Arguments.Contains("tag")) { runner.Tag = Arguments["tag"]; } runner.NoTestsDiscovered += (o, e) => OutLineFormat("No tests were found in {0}", ConsoleColor.Yellow, assembly.FullName); runner.TestsDiscovered += (o, e) => { TestsDiscoveredEventArgs <TTestMethod> args = (TestsDiscoveredEventArgs <TTestMethod>)e; OutLineFormat("Running all tests in {0}", ConsoleColor.Green, args.Assembly.FullName); OutLineFormat("\tFound {0} tests", ConsoleColor.Cyan, args.Tests.Count); }; runner.TestPassed += (o, e) => { TestEventArgs <TTestMethod> args = (TestEventArgs <TTestMethod>)e; Pass(args.Test.Information); }; runner.TestFailed += (o, t) => { TestExceptionEventArgs args = (TestExceptionEventArgs)t; Out("Test Failed: " + args.TestMethod.Information + "\r\n", ConsoleColor.Red); Out(args.Exception.Message, ConsoleColor.Magenta); Out(); Out(args.Exception.StackTrace, ConsoleColor.Red); Out("---", ConsoleColor.Red); Out(); }; runner.TestsFinished += (o, e) => { TestEventArgs <TTestMethod> args = (TestEventArgs <TTestMethod>)e; TestRunnerSummary summary = args.TestRunner.TestSummary; Out(); OutLine("********"); if (summary.FailedTests.Count > 0) { OutLineFormat("({0}) tests passed", ConsoleColor.Green, summary.PassedTests.Count); OutLineFormat("({0}) tests failed", ConsoleColor.Red, summary.FailedTests.Count); summary.FailedTests.ForEach(cim => { Out("\t"); MethodInfo method = cim.Test.Method; Type type = method.DeclaringType; string testIdentifier = $"{type.Namespace}.{type.Name}.{method.Name}"; OutLineFormat("{0}: ({1})", new ConsoleColorCombo(ConsoleColor.Yellow, ConsoleColor.Red), cim.Test.Information, testIdentifier); }); } else { OutLineFormat("All ({0}) tests passed", ConsoleColor.Green, summary.PassedTests.Count); } OutLine("********"); }; return(runner); }
public virtual void TestFinished(object sender, TestEventArgs <TTestMethod> args) { }
public virtual void TestStarting(object sender, TestEventArgs <TTestMethod> args) { }
public abstract void TestPassed(object sender, TestEventArgs <TTestMethod> args);
public override void TestsFinished(object sender, TestEventArgs <UnitTestMethod> args) { base.TestsFinished(sender, args); TestsFinishedAction?.Invoke(args); }