void HandleTestSkipped(MessageHandlerArgs <ITestSkipped> args) { var test = conversions[args.Message.TestCase]; sink?.SendTestResult(new TestResult(test) { Outcome = TestOutcome.Skipped }); }
public void SendTestResult() { var testResult = CreateMockTestResult(); _testSink.SendTestResult(testResult); var message = GetMessage(); Assert.That(message, Is.Not.Null); Assert.That(message.MessageType, Is.EqualTo(Messages.TestResult)); AssertAreEqual(testResult, GetPayload <MsTestResult>(message)); }
protected override bool Visit(ITestSkipped testSkipped) { var test = _conversions[testSkipped.TestCase]; _sink?.SendTestResult(new TestResult(test) { Outcome = TestOutcome.Skipped }); return(true); }
void OnTestCase(XElement xml) { var testResult = ParseTestResult(xml); if (Options.DesignTime) { _sink?.SendTestResult(testResult); } }
void OnTestCase(XElement xml) { var testResult = ParseTestResult(xml); string output = null; if (testResult.Messages.Count > 0) { output = testResult.Messages[0]; } else if (testResult.Outcome != TestOutcome.None) { output = testResult.Outcome.ToString(); } TestFinished?.Invoke(this, new TestEventArgs(testResult.Test.FullyQualifiedName, output)); if (Options.DesignTime) { _sink?.SendTestResult(testResult); } }
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()); }