private void DiscoverTests(TestOptions options, IFrontController frontController, IServiceProvider services) { var visitor = new DiscoveryVisitor((services.GetService(typeof(ITestSinkFactory)) as ITestSinkFactory)?.CreateDiscoverySink(services) ?? new DefaultTestDiscoverySink()); frontController.Find(true, visitor, options); visitor.Finished.WaitOne(); }
public static INativeTest BuildSuiteForTextContext(FixtureContext fixtureContext, TestContext testContext1, Action invoke, bool isRootSuite, string explicitReason = null) { var result = fixtureContext.NativeTestFactory.ForSuite(fixtureContext, testContext1); if (explicitReason != null) { result.MarkTestIgnored(explicitReason); } var builder = new DiscoveryVisitor(result, fixtureContext, testContext1.FixtureContext.GlobalSetupManager); var exception = fixtureContext.RunActionWithVisitor(testContext1.Position.GetFirstChildPosition(), invoke, builder); if (exception == null) { builder.VisitAccumulatedTests(result.AddChild); } else { var failedTestPositon = isRootSuite ? testContext1.Position.GetFirestUnexpectedChildPosition() : testContext1.Position; var testContext = new TestContext() { Name = fixtureContext.NameReservations.GetReservedNameLike(result.Name), Position = failedTestPositon, FixtureContext = testContext1.FixtureContext }; var failingSuiteAsTest = fixtureContext.NativeTestFactory.ForTest(fixtureContext, testContext); failingSuiteAsTest.MarkTestFailed(exception); if (isRootSuite) { result.AddChild(failingSuiteAsTest); } else { return(failingSuiteAsTest); } } return(result); }
public static INativeTest BuildSuiteForTextContext(FixtureContext fixtureContext, TestContext testContext1, Action invoke, bool isRootSuite, string explicitReason = null) { var result = fixtureContext.NativeTestFactory.ForSuite(fixtureContext, testContext1); if (explicitReason != null) result.MarkTestIgnored(explicitReason); var builder = new DiscoveryVisitor(result, fixtureContext, testContext1.FixtureContext.GlobalSetupManager); var exception = fixtureContext.RunActionWithVisitor(testContext1.Position.GetFirstChildPosition(), invoke, builder); if (exception == null) { builder.VisitAccumulatedTests(result.AddChild); } else { var failedTestPositon = isRootSuite ? testContext1.Position.GetFirestUnexpectedChildPosition() : testContext1.Position; var testContext = new TestContext() { Name = fixtureContext.NameReservations.GetReservedNameLike(result.Name), Position = failedTestPositon, FixtureContext = testContext1.FixtureContext }; var failingSuiteAsTest = fixtureContext.NativeTestFactory.ForTest(fixtureContext, testContext); failingSuiteAsTest.MarkTestFailed(exception); if (isRootSuite) { result.AddChild(failingSuiteAsTest); } else { return failingSuiteAsTest; } } return result; }