Exemple #1
0
        /// <inheritdoc/>
        public void FindAndRun(
            _IMessageSink messageSink,
            FrontControllerFindAndRunSettings settings)
        {
            Guard.NotNull($"This instance of {typeof(Xunit2).FullName} was created for discovery only; execution-related operations cannot be performed.", remoteExecutor);

            Guard.ArgumentNotNull(messageSink);
            Guard.ArgumentNotNull(settings);

            if (settings.Filters.Empty)
            {
                remoteExecutor.RunAll(
                    CreateOptimizedRemoteMessageSink(messageSink),
                    Xunit2OptionsAdapter.Adapt(settings.DiscoveryOptions),
                    Xunit2OptionsAdapter.Adapt(settings.ExecutionOptions)
                    );

                return;
            }

            using var discoverySink = new Xunit2DiscoverySink(settings.Filters);
            remoteDiscoverer.Find(
                includeSourceInformation: false,
                discoverySink,
                Xunit2OptionsAdapter.Adapt(settings.DiscoveryOptions)
                );
            discoverySink.Finished.WaitOne();

            remoteExecutor.RunTests(
                discoverySink.TestCases,
                CreateOptimizedRemoteMessageSink(messageSink),
                Xunit2OptionsAdapter.Adapt(settings.ExecutionOptions)
                );
        }
Exemple #2
0
        /// <inheritdoc/>
        public void Run(
            _IMessageSink messageSink,
            FrontControllerRunSettings settings)
        {
            Guard.NotNull($"This instance of {typeof(Xunit2).FullName} was created for discovery only; execution-related operations cannot be performed.", remoteExecutor);

            Guard.ArgumentNotNull(messageSink);
            Guard.ArgumentNotNull(settings);

            remoteExecutor.RunTests(
                BulkDeserialize(settings.SerializedTestCases.ToList()).Select(kvp => kvp.Value).ToList(),
                CreateOptimizedRemoteMessageSink(messageSink),
                Xunit2OptionsAdapter.Adapt(settings.Options)
                );
        }
Exemple #3
0
        /// <inheritdoc/>
        public void Find(
            _IMessageSink messageSink,
            FrontControllerFindSettings settings)
        {
            Guard.ArgumentNotNull(messageSink);
            Guard.ArgumentNotNull(settings);

            var includeSourceInformation = settings.Options.GetIncludeSourceInformationOrDefault();
            var filteringMessageSink     = new FilteringMessageSink(messageSink, settings.Filters.Filter);

            // TODO: We're missing a potential optimization where we could determine that the filter
            // is exactly 1 (or maybe only?) "include class" filters, and then call the version of
            // Find on the remote discoverer that takes a type name.
            SendDiscoveryStartingMessage(messageSink);
            remoteDiscoverer.Find(
                includeSourceInformation,
                CreateOptimizedRemoteMessageSink(filteringMessageSink),
                Xunit2OptionsAdapter.Adapt(settings.Options)
                );
        }