Esempio n. 1
0
 public void Setup()
 {
     context = new TestRunContext(
         new DefaultServiceProvider(),
         new Mock <ITestLogAccessor>().Object);
     runHooks = new RunHooks(context, new[] { Assembly.GetExecutingAssembly() });
 }
Esempio n. 2
0
        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();
            }
        }