public async Task ExecuteMethodsMarkedForBeforeRun() { var initialCount = HookSamples.BeforeRunCallCount; await runHooks.ExecuteBeforeRun(); Assert.AreEqual(initialCount + 1, HookSamples.BeforeRunCallCount); }
private void RunMappedTests(IEnumerable <TestCase> mappedTests, IFrameworkHandle frameworkHandle) { frameworkHandle.SendMessage(TestMessageLevel.Informational, "Running tests"); using (var defaultServiceProvider = new DefaultServiceProvider()) { var testRunContext = (TestRunContext)defaultServiceProvider.GetService( typeof(TestRunContext)); var runHooks = new RunHooks( testRunContext, mappedTests .Select( test => test .DiscoveredData() .Assembly) .Distinct()); runHooks.ExecuteBeforeRun().Wait(); var stepBinder = new StepBinder(); var tasks = new List <Task>(); foreach (var testCase in mappedTests) { if (isCancelling) { frameworkHandle.SendMessage(TestMessageLevel.Informational, "Test run cancelled"); break; } if (testCase.DiscoveredData().IsIgnored) { testCase.MarkAsSkipped(frameworkHandle); continue; } tasks.Add( RunMappedTest(testCase, testCase.DiscoveredData(), testRunContext, stepBinder, frameworkHandle)); } Task.WhenAll(tasks).Wait(); runHooks.ExecuteAfterRun().Wait(); } }