/// <summary> /// Discovers tests /// </summary> /// <param name="discoveryCriteria">Settings, parameters for the discovery request</param> /// <param name="eventHandler">EventHandler for handling discovery events from Engine</param> public void DiscoverTests(DiscoveryCriteria discoveryCriteria, ITestDiscoveryEventsHandler eventHandler) { var discoveryResultCache = new DiscoveryResultCache( discoveryCriteria.FrequencyOfDiscoveredTestsEvent, discoveryCriteria.DiscoveredTestEventTimeout, this.OnReportTestCases); try { EqtTrace.Info("TestDiscoveryManager.DoDiscovery: Background test discovery started."); this.testDiscoveryEventsHandler = eventHandler; var verifiedExtensionSourceMap = new Dictionary <string, IEnumerable <string> >(); // Validate the sources foreach (var kvp in discoveryCriteria.AdapterSourceMap) { var verifiedSources = GetValidSources(kvp.Value, this.sessionMessageLogger); if (verifiedSources.Any()) { verifiedExtensionSourceMap.Add(kvp.Key, kvp.Value); } } // If there are sources to discover if (verifiedExtensionSourceMap.Any()) { new DiscovererEnumerator(discoveryResultCache).LoadTests( verifiedExtensionSourceMap, RunSettingsUtilities.CreateAndInitializeRunSettings(discoveryCriteria.RunSettings), this.sessionMessageLogger); } } finally { // Discovery complete. Raise the DiscoveryCompleteEvent. EqtTrace.Verbose("TestDiscoveryManager.DoDiscovery: Background Test Discovery complete."); var totalDiscoveredTestCount = discoveryResultCache.TotalDiscoveredTests; var lastChunk = discoveryResultCache.Tests; EqtTrace.Verbose("TestDiscoveryManager.DiscoveryComplete: Calling DiscoveryComplete callback."); if (eventHandler != null) { eventHandler.HandleDiscoveryComplete(totalDiscoveredTestCount, lastChunk, false); } else { EqtTrace.Warning( "DiscoveryManager: Could not pass the discovery complete message as the callback is null."); } EqtTrace.Verbose("TestDiscoveryManager.DiscoveryComplete: Called DiscoveryComplete callback."); this.testDiscoveryEventsHandler = null; } }
/// <summary> /// Initializes a new instance of the <see cref="DiscovererEnumerator"/> class. /// </summary> /// <param name="requestData">The request data for providing discovery services and data.</param> /// <param name="discoveryResultCache"> The discovery result cache. </param> /// <param name="testPlatformEventSource">Telemetry events receiver</param> /// <param name="token">Cancellation Token to abort discovery</param> public DiscovererEnumerator(IRequestData requestData, DiscoveryResultCache discoveryResultCache, ITestPlatformEventSource testPlatformEventSource, CancellationToken token) : this(requestData, discoveryResultCache, testPlatformEventSource, new AssemblyProperties(), token) { }
internal DiscovererEnumerator( DiscoveryResultCache discoveryResultCache, ITestPlatformEventSource testPlatformEventSource) { this.discoveryResultCache = discoveryResultCache; this.testPlatformEventSource = testPlatformEventSource; }
internal DiscovererEnumerator(IRequestData requestData, DiscoveryResultCache discoveryResultCache, ITestPlatformEventSource testPlatformEventSource) { this.discoveryResultCache = discoveryResultCache; this.testPlatformEventSource = testPlatformEventSource; this.requestData = requestData; }
internal DiscovererEnumerator(IRequestData requestData, DiscoveryResultCache discoveryResultCache, ITestPlatformEventSource testPlatformEventSource) { this.discoveryResultCache = discoveryResultCache; this.testPlatformEventSource = testPlatformEventSource; this.requestData = requestData; this.assemblyProperties = new AssemblyProperties(); }
/// <summary> /// Initializes a new instance of the <see cref="DiscovererEnumerator"/> class. /// </summary> /// <param name="requestData">The request data for providing discovery services and data.</param> /// <param name="discoveryResultCache"> The discovery result cache. </param> /// <param name="testPlatformEventSource">Telemetry events receiver</param> /// <param name="assemblyProperties">Information on the assemblies being discovered</param> /// <param name="token">Cancellation Token to abort discovery</param> public DiscovererEnumerator(IRequestData requestData, DiscoveryResultCache discoveryResultCache, ITestPlatformEventSource testPlatformEventSource, IAssemblyProperties assemblyProperties, CancellationToken token) { // Added this to make class testable, needed a PEHeader mocked Instance this.discoveryResultCache = discoveryResultCache; this.testPlatformEventSource = testPlatformEventSource; this.requestData = requestData; this.assemblyProperties = assemblyProperties; this.cancellationToken = token; }
/// <summary> /// Discovers tests /// </summary> /// <param name="discoveryCriteria">Settings, parameters for the discovery request</param> /// <param name="eventHandler">EventHandler for handling discovery events from Engine</param> public void DiscoverTests(DiscoveryCriteria discoveryCriteria, ITestDiscoveryEventsHandler2 eventHandler) { var discoveryResultCache = new DiscoveryResultCache( discoveryCriteria.FrequencyOfDiscoveredTestsEvent, discoveryCriteria.DiscoveredTestEventTimeout, this.OnReportTestCases); try { this.discoveryCriteria = discoveryCriteria; EqtTrace.Info("TestDiscoveryManager.DoDiscovery: Background test discovery started."); this.testDiscoveryEventsHandler = eventHandler; var verifiedExtensionSourceMap = new Dictionary <string, IEnumerable <string> >(); // Validate the sources foreach (var kvp in discoveryCriteria.AdapterSourceMap) { var verifiedSources = GetValidSources(kvp.Value, this.sessionMessageLogger); if (verifiedSources.Any()) { verifiedExtensionSourceMap.Add(kvp.Key, kvp.Value); } } // If there are sources to discover if (verifiedExtensionSourceMap.Any()) { new DiscovererEnumerator(this.requestData, discoveryResultCache, cancellationTokenSource.Token).LoadTests( verifiedExtensionSourceMap, RunSettingsUtilities.CreateAndInitializeRunSettings(discoveryCriteria.RunSettings), discoveryCriteria.TestCaseFilter, this.sessionMessageLogger); } } finally { // Discovery complete. Raise the DiscoveryCompleteEvent. EqtTrace.Verbose("TestDiscoveryManager.DoDiscovery: Background Test Discovery complete."); var totalDiscoveredTestCount = discoveryResultCache.TotalDiscoveredTests; var lastChunk = discoveryResultCache.Tests; EqtTrace.Verbose("TestDiscoveryManager.DiscoveryComplete: Calling DiscoveryComplete callback."); if (eventHandler != null) { if (lastChunk != null) { UpdateTestCases(lastChunk, this.discoveryCriteria.Package); } // Collecting Discovery State this.requestData.MetricsCollection.Add(TelemetryDataConstants.DiscoveryState, "Completed"); // Collecting Total Tests Discovered this.requestData.MetricsCollection.Add(TelemetryDataConstants.TotalTestsDiscovered, totalDiscoveredTestCount); var discoveryCompleteEventsArgs = new DiscoveryCompleteEventArgs(totalDiscoveredTestCount, false) { Metrics = this.requestData.MetricsCollection.Metrics }; eventHandler.HandleDiscoveryComplete(discoveryCompleteEventsArgs, lastChunk); } else { EqtTrace.Warning( "DiscoveryManager: Could not pass the discovery complete message as the callback is null."); } EqtTrace.Verbose("TestDiscoveryManager.DiscoveryComplete: Called DiscoveryComplete callback."); this.testDiscoveryEventsHandler = null; } }
/// <summary> /// Initializes a new instance of the <see cref="DiscovererEnumerator"/> class. /// </summary> /// <param name="requestData">The request data for providing discovery services and data.</param> /// <param name="discoveryResultCache"> The discovery result cache. </param> public DiscovererEnumerator(IRequestData requestData, DiscoveryResultCache discoveryResultCache, CancellationToken token) : this(requestData, discoveryResultCache, TestPlatformEventSource.Instance, token) { }
/// <summary> /// Initializes a new instance of the <see cref="DiscovererEnumerator"/> class. /// </summary> /// <param name="requestData">The request data for providing discovery services and data.</param> /// <param name="discoveryResultCache"> The discovery result cache. </param> /// <param name="metricsCollector">Metric Collector</param> public DiscovererEnumerator(IRequestData requestData, DiscoveryResultCache discoveryResultCache) : this(requestData, discoveryResultCache, TestPlatformEventSource.Instance) { }
/// <summary> /// Initializes a new instance of the <see cref="TestCaseDiscoverySink"/> class. /// </summary> /// <param name="discoveryRequestCache"> The discovery request cache. </param> internal TestCaseDiscoverySink(DiscoveryResultCache discoveryRequestCache) { this.discoveryRequestCache = discoveryRequestCache; }
/// <summary> /// Initializes a new instance of the <see cref="DiscovererEnumerator"/> class. /// </summary> /// <param name="discoveryResultCache"> The discovery result cache. </param> /// <param name="testPlatformEventSource1"></param> public DiscovererEnumerator(DiscoveryResultCache discoveryResultCache) : this(discoveryResultCache, TestPlatformEventSource.Instance) { }