public void SendTestStarted() { var test = CreateMockTest(); _testSink.SendTestStarted(test); var message = GetMessage(); Assert.That(message, Is.Not.Null); Assert.That(message.MessageType, Is.EqualTo(Messages.TestStarted)); AssertAreEqual(test, GetPayload <MsTest>(message)); }
protected override bool Visit(ITestStarting testStarting) { var test = _conversions[testStarting.TestCase]; _sink?.SendTestStarted(test); return(true); }
void OnStartTest(XElement xml) { var test = ParseTest(xml); if (Options.DesignTime) { _sink?.SendTestStarted(test); } }
void OnStartTest(XElement xml) { var test = ParseTest(xml); TestStarted?.Invoke(this, new TestEventArgs(test.FullyQualifiedName, null)); if (Options.DesignTime) { _sink?.SendTestStarted(test); } }
int Execute() { var designTimeFullyQualifiedNames = SetupSinks(args); var results = new List <TestResultWrapper>(); foreach (var assembly in args.Inputs) { var assemblyPath = Path.GetFullPath(assembly); var testAssembly = LoadAssembly(assemblyPath); var libraryPath = Path.Combine(Path.GetDirectoryName(assemblyPath), "Persimmon.dll"); var library = LoadAssembly(libraryPath); var driver = new PersimmonDriver(library, testAssembly); var tests = driver.CollectTests(); if (args.DesignTime && designTimeFullyQualifiedNames.Any()) { tests = tests.Where(t => designTimeFullyQualifiedNames.Contains(t.Test.FullyQualifiedName)); } if (args.List) { foreach (var test in tests) { testDiscoverySink.SendTestFound(test.Test); } } else { Action <object> before = testCase => { if (args.DesignTime) { testExecutionSink.SendTestStarted(new TestCaseWrapper(testCase).Test); } }; Action <object> progress = result => { var wrapper = new TestResultWrapper(result); // TODO: send async //if (args.DesignTime) //{ // testExecutionSink.SendTestResult(wrapper.TestResult); //} //else if (!args.DesignTime) { switch (wrapper.TestResult.Outcome) { case TestOutcome.Passed: Console.Write("."); break; case TestOutcome.Failed: if (wrapper.Exceptions.Any()) { Console.Write("E"); } else { Console.Write("x"); } break; case TestOutcome.Skipped: Console.Write("_"); break; default: break; } } results.Add(wrapper); }; driver.RunTests(tests.Select(t => t.Test.FullyQualifiedName).ToArray(), before, progress); } } // TODO: remove after implement `send async` if (args.DesignTime) { foreach (var wrapper in results) { testExecutionSink.SendTestResult(wrapper.TestResult); } } if (args.List) { if (args.DesignTime) { testDiscoverySink.SendTestCompleted(); } return(0); } if (args.DesignTime) { testExecutionSink.SendTestCompleted(); return(0); } var reporter = new Reporter(results, ColorConsole); reporter.Report(); return(results.Where(r => r.TestResult.Outcome == TestOutcome.Failed).Count()); }
void HandleTestStarting(MessageHandlerArgs <ITestStarting> args) { var test = conversions[args.Message.TestCase]; sink?.SendTestStarted(test); }