コード例 #1
0
        public void RunTests(IEnumerable <TestCase> tests, IRunContext runContext, IFrameworkHandle frameworkHandle)
        {
            try
            {
                var sources = tests
                              .Select(test => test.Source)
                              .Distinct();

                var testsMappedToScenarios = TestDiscoverer
                                             .DiscoverTests(sources, frameworkHandle)
                                             .ToArray();

                var unmappedTests = tests
                                    .Where(test => !testsMappedToScenarios.Any(mappedTest => mappedTest.Id == test.Id));

                unmappedTests.MarkAsNotFound(frameworkHandle);

                var mappedTests = tests
                                  .Select(
                    test => testsMappedToScenarios
                    .FirstOrDefault(
                        mappedTest => mappedTest.Id == test.Id))
                                  .Where(test => test != null);

                RunMappedTests(mappedTests, frameworkHandle);
            }
            catch (Exception exception)
            {
                frameworkHandle.SendMessage(
                    TestMessageLevel.Error,
                    $"Skipping test run because of an early exception: {exception}");

                tests.TryMarkAsFailed(frameworkHandle, exception.Message, exception.StackTrace);
            }
        }
コード例 #2
0
        public void RunTests(IEnumerable <string> sources, IRunContext runContext, IFrameworkHandle frameworkHandle)
        {
            var tests = Enumerable.Empty <TestCase>();

            try
            {
                tests = TestDiscoverer.DiscoverTests(sources, frameworkHandle);

                RunMappedTests(tests, frameworkHandle);
            }
            catch (Exception exception)
            {
                frameworkHandle.SendMessage(
                    TestMessageLevel.Error,
                    $"Skipping test run because of an early exception: {exception}");

                tests.TryMarkAsFailed(frameworkHandle, exception.Message, exception.StackTrace);
            }
        }