/// <summary> /// Returns an IBoostTestDiscoverer based on the provided source. /// </summary> /// <param name="factory">The factory to utilise.</param> /// <param name="source">Source to be associated.</param> /// <param name="settings">A structure which states particular features of interest in the manufactured product.</param> /// <returns>An IBoostTestDiscoverer instance or null if one cannot be provided.</returns> public static IBoostTestDiscoverer GetDiscoverer(this IBoostTestDiscovererFactory factory, string source, Settings.BoostTestAdapterSettings settings) { Utility.Code.Require(factory, "factory"); var list = new[] { source }; var results = factory.GetDiscoverers(list, settings); if (results != null) { var result = results.FirstOrDefault(x => x.Sources.Contains(source)); if (result != null) { return(result.Discoverer); } } return(null); }
public void DiscoverTests(IEnumerable <string> sources, IDiscoveryContext discoveryContext, ITestCaseDiscoverySink discoverySink) { if (sources == null) { return; } BoostTestAdapterSettings settings = BoostTestAdapterSettingsProvider.GetSettings(discoveryContext); try { // Filter out any sources which are not of interest if (!TestSourceFilter.IsNullOrEmpty(settings.Filters)) { sources = sources.Where(settings.Filters.ShouldInclude); } var results = _boostTestDiscovererFactory.GetDiscoverers(sources.ToList(), settings); if (results == null) { return; } // Test discovery foreach (var discoverer in results) { if (discoverer.Sources.Count > 0) { Logger.Info("Discovering ({0}): -> [{1}]", discoverer.Discoverer.GetType().Name, string.Join(", ", discoverer.Sources)); discoverer.Discoverer.DiscoverTests(discoverer.Sources, discoveryContext, discoverySink); } } } catch (Exception ex) { Logger.Exception(ex, "Exception caught while discovering tests: {0} ({1})", ex.Message, ex.HResult); } }