Best Vstest code snippet using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Tracing.TestPlatformEventSource.DiscoveryStart
DiscovererEnumerator.cs
Source:DiscovererEnumerator.cs
...54 /// <param name="testCaseFilter"> The test case filter. </param>55 /// <param name="logger"> The logger. </param>56 internal void LoadTests(IDictionary<string, IEnumerable<string>> testExtensionSourceMap, IRunSettings settings, string testCaseFilter, IMessageLogger logger)57 {58 this.testPlatformEventSource.DiscoveryStart();59 foreach (var kvp in testExtensionSourceMap)60 {61 this.LoadTestsFromAnExtension(kvp.Key, kvp.Value, settings, testCaseFilter, logger);62 }63 this.testPlatformEventSource.DiscoveryStop(this.discoveryResultCache.TotalDiscoveredTests);64 }65 /// <summary>66 /// Loads test cases from individual source. 67 /// Discovery extensions update progress through ITestCaseDiscoverySink.68 /// Discovery extensions sends discovery messages through TestRunMessageLoggerProxy69 /// </summary>70 /// <param name="extensionAssembly"> The extension Assembly. </param>71 /// <param name="sources"> The sources. </param>72 /// <param name="settings"> The settings. </param>73 /// <param name="settings"> The test case filter. </param>74 /// <param name="logger"> The logger. </param>75 [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes",76 Justification = "This methods must invoke all possible discoverers and not fail or crash in any one.")]77 private void LoadTestsFromAnExtension(string extensionAssembly, IEnumerable<string> sources, IRunSettings settings, string testCaseFilter, IMessageLogger logger)78 {79 double totalAdaptersUsed = 0;80 // Stopwatch to collect metrics81 var timeStart = DateTime.UtcNow;82 var discovererToSourcesMap = GetDiscovererToSourcesMap(extensionAssembly, sources, logger);83 var totalAdapterLoadTIme = DateTime.UtcNow - timeStart;84 // Collecting Data Point for TimeTaken to Load Adapters85 this.requestData.MetricsCollection.Add(TelemetryDataConstants.TimeTakenToLoadAdaptersInSec, totalAdapterLoadTIme.TotalSeconds);86 // Warning is logged for in the inner function87 if (discovererToSourcesMap == null || !discovererToSourcesMap.Any())88 {89 return;90 }91 // Collecting Total Number of Adapters Discovered in Machine92 this.requestData.MetricsCollection.Add(TelemetryDataConstants.NumberOfAdapterDiscoveredDuringDiscovery, discovererToSourcesMap.Keys.Count());93 var context = new DiscoveryContext { RunSettings = settings };94 context.FilterExpressionWrapper = !string.IsNullOrEmpty(testCaseFilter) ? new FilterExpressionWrapper(testCaseFilter) : null;95 // Set on the logger the TreatAdapterErrorAsWarning setting from runsettings.96 this.SetAdapterLoggingSettings(logger, settings);97 var discoverySink = new TestCaseDiscoverySink(this.discoveryResultCache);98 double totalTimeTakenByAdapters = 0;99 foreach (var discoverer in discovererToSourcesMap.Keys)100 {101 Type discovererType = null;102 // See if discoverer can be instantiated successfully else move next.103 try104 {105 discovererType = discoverer.Value.GetType();106 }107 catch (Exception e)108 {109 var mesage = string.Format(110 CultureInfo.CurrentUICulture,111 CrossPlatEngineResources.DiscovererInstantiationException,112 e.Message);113 logger.SendMessage(TestMessageLevel.Warning, mesage);114 EqtTrace.Error(e);115 continue;116 }117 // if instantiated successfully, get tests118 try119 {120 if (EqtTrace.IsVerboseEnabled)121 {122 EqtTrace.Verbose(123 "DiscoveryContext.LoadTests: Loading tests for {0}",124 discoverer.Value.GetType().FullName);125 }126 var currentTotalTests = this.discoveryResultCache.TotalDiscoveredTests;127 var newTimeStart = DateTime.UtcNow;128 this.testPlatformEventSource.AdapterDiscoveryStart(discoverer.Metadata.DefaultExecutorUri.AbsoluteUri);129 discoverer.Value.DiscoverTests(discovererToSourcesMap[discoverer], context, logger, discoverySink);130 var totalAdapterRunTime = DateTime.UtcNow - newTimeStart;131 this.testPlatformEventSource.AdapterDiscoveryStop(this.discoveryResultCache.TotalDiscoveredTests - currentTotalTests);132 // Collecting Total Tests Discovered By each Adapter.133 if (this.discoveryResultCache.TotalDiscoveredTests > currentTotalTests)134 {135 var totalDiscoveredTests = this.discoveryResultCache.TotalDiscoveredTests - currentTotalTests;136 this.requestData.MetricsCollection.Add(string.Format("{0}.{1}", TelemetryDataConstants.TotalTestsByAdapter, discoverer.Metadata.DefaultExecutorUri), totalDiscoveredTests);137 totalAdaptersUsed++;138 }139 if (EqtTrace.IsVerboseEnabled)140 {141 EqtTrace.Verbose(142 "DiscoveryContext.LoadTests: Done loading tests for {0}",...
TestPlatformEventSource.cs
Source:TestPlatformEventSource.cs
...103 {104 this.WriteEvent(TestPlatformInstrumentationEvents.AdapterExecutionStopEventId, numberOfTests);105 }106 /// <inheritdoc/>107 [Event(TestPlatformInstrumentationEvents.AdapterDiscoveryStartEventId)]108 public void AdapterDiscoveryStart(string executorUri)109 {110 this.WriteEvent(TestPlatformInstrumentationEvents.AdapterDiscoveryStartEventId, executorUri);111 }112 /// <inheritdoc/>113 [Event(TestPlatformInstrumentationEvents.AdapterDiscoveryStopEventId)]114 public void AdapterDiscoveryStop(long numberOfTests)115 {116 this.WriteEvent(TestPlatformInstrumentationEvents.AdapterDiscoveryStopEventId, numberOfTests);117 }118 /// <inheritdoc/>119 [Event(TestPlatformInstrumentationEvents.DiscoveryStartEventId)]120 public void DiscoveryStart()121 {122 this.WriteEvent(TestPlatformInstrumentationEvents.DiscoveryStartEventId);123 }124 /// <inheritdoc/>125 [Event(TestPlatformInstrumentationEvents.DiscoveryStopEventId)]126 public void DiscoveryStop(long numberOfTests)127 {128 this.WriteEvent(TestPlatformInstrumentationEvents.DiscoveryStopEventId, numberOfTests);129 }130 /// <inheritdoc/>131 [Event(TestPlatformInstrumentationEvents.ExecutionStartEventId)]132 public void ExecutionStart()133 {134 this.WriteEvent(TestPlatformInstrumentationEvents.ExecutionStartEventId);135 }136 /// <inheritdoc/>137 [Event(TestPlatformInstrumentationEvents.ExecutionStopEventId)]138 public void ExecutionStop(long numberOfTests)139 {140 this.WriteEvent(TestPlatformInstrumentationEvents.ExecutionStopEventId, numberOfTests);141 }142 /// <inheritdoc/>143 [Event(TestPlatformInstrumentationEvents.DataCollectionStartEventId)]144 public void DataCollectionStart(string dataCollectorUri)145 {146 this.WriteEvent(TestPlatformInstrumentationEvents.DataCollectionStartEventId, dataCollectorUri);147 }148 /// <inheritdoc/>149 [Event(TestPlatformInstrumentationEvents.DataCollectionStopEventId)]150 public void DataCollectionStop()151 {152 this.WriteEvent(TestPlatformInstrumentationEvents.DataCollectionStopEventId);153 }154 /// <inheritdoc/>155 [Event(TestPlatformInstrumentationEvents.TranslationLayerInitializeStartEventId)]156 public void TranslationLayerInitializeStart()157 {158 this.WriteEvent(TestPlatformInstrumentationEvents.TranslationLayerInitializeStartEventId);159 }160 /// <inheritdoc/>161 [Event(TestPlatformInstrumentationEvents.TranslationLayerInitializeStopEventId)]162 public void TranslationLayerInitializeStop()163 {164 this.WriteEvent(TestPlatformInstrumentationEvents.TranslationLayerInitializeStopEventId);165 }166 /// <inheritdoc/>167 [Event(TestPlatformInstrumentationEvents.TranslationLayerDiscoveryStartEventId)]168 public void TranslationLayerDiscoveryStart()169 {170 this.WriteEvent(TestPlatformInstrumentationEvents.TranslationLayerDiscoveryStartEventId);171 }172 /// <inheritdoc/>173 [Event(TestPlatformInstrumentationEvents.TranslationLayerDiscoveryStopEventId)]174 public void TranslationLayerDiscoveryStop()175 {176 this.WriteEvent(TestPlatformInstrumentationEvents.TranslationLayerDiscoveryStopEventId);177 }178 /// <inheritdoc/>179 [Event(TestPlatformInstrumentationEvents.TranslationLayerExecutionStartEventId)]180 public void TranslationLayerExecutionStart(long customTestHost, long sourcesCount, long testCasesCount, string runSettings)181 {182 this.WriteEvent(183 TestPlatformInstrumentationEvents.TranslationLayerExecutionStartEventId,184 customTestHost,...
DiscoveryStart
Using AI Code Generation
1using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Tracing;2TestPlatformEventSource.Instance.DiscoveryStart();3using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Tracing;4TestPlatformEventSource.Instance.DiscoveryStart();5using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Tracing;6TestPlatformEventSource.Instance.DiscoveryStart();7using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Tracing;8TestPlatformEventSource.Instance.DiscoveryStart();9using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Tracing;10TestPlatformEventSource.Instance.DiscoveryStart();11using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Tracing;12TestPlatformEventSource.Instance.DiscoveryStart();13using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Tracing;14TestPlatformEventSource.Instance.DiscoveryStart();15using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Tracing;16TestPlatformEventSource.Instance.DiscoveryStart();17using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Tracing;18TestPlatformEventSource.Instance.DiscoveryStart();19using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Tracing;20TestPlatformEventSource.Instance.DiscoveryStart();21using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Tracing;
DiscoveryStart
Using AI Code Generation
1using System;2{3 {4 static void Main(string[] args)5 {6 Microsoft.VisualStudio.TestPlatform.CoreUtilities.Tracing.TestPlatformEventSource.Instance.DiscoveryStart();7 }8 }9}10using System;11{12 {13 static void Main(string[] args)14 {15 Microsoft.VisualStudio.TestPlatform.CoreUtilities.Tracing.TestPlatformEventSource.Instance.DiscoveryStart();16 }17 }18}19using System;20{21 {22 static void Main(string[] args)23 {24 Microsoft.VisualStudio.TestPlatform.CoreUtilities.Tracing.TestPlatformEventSource.Instance.DiscoveryStart();25 }26 }27}28using System;29{30 {31 static void Main(string[] args)32 {33 Microsoft.VisualStudio.TestPlatform.CoreUtilities.Tracing.TestPlatformEventSource.Instance.DiscoveryStart();34 }35 }36}37using System;38{39 {40 static void Main(string[] args)41 {42 Microsoft.VisualStudio.TestPlatform.CoreUtilities.Tracing.TestPlatformEventSource.Instance.DiscoveryStart();43 }44 }45}46using System;47{48 {49 static void Main(string[] args)50 {51 Microsoft.VisualStudio.TestPlatform.CoreUtilities.Tracing.TestPlatformEventSource.Instance.DiscoveryStart();52 }53 }54}55using System;56{57 {58 static void Main(string[] args)59 {
DiscoveryStart
Using AI Code Generation
1using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Tracing;2using System;3using System.Diagnostics.Tracing;4{5 {6 static void Main(string[] args)7 {8 EventSource eventSource = TestPlatformEventSource.Instance;9 EventListener eventListener = new EventListener();10 eventListener.EnableEvents(eventSource, EventLevel.LogAlways, (EventKeywords)0x0000000000000001);11 TestPlatformEventSource.Instance.DiscoveryStart();12 Console.ReadLine();13 }14 }15}16using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Tracing;17using System;18using System.Diagnostics.Tracing;19{20 {21 static void Main(string[] args)22 {23 EventSource eventSource = TestPlatformEventSource.Instance;24 EventListener eventListener = new EventListener();25 eventListener.EnableEvents(eventSource, EventLevel.LogAlways, (EventKeywords)0x0000000000000001);26 TestPlatformEventSource.Instance.DiscoveryStart();27 Console.ReadLine();28 }29 }30}31using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Tracing;32using System;33using System.Diagnostics.Tracing;34{35 {36 static void Main(string[] args)37 {38 EventSource eventSource = TestPlatformEventSource.Instance;39 EventListener eventListener = new EventListener();40 eventListener.EnableEvents(eventSource, EventLevel.LogAlways, (EventKeywords)0x0000000000000001);41 TestPlatformEventSource.Instance.DiscoveryStart();42 Console.ReadLine();43 }44 }45}46using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Tracing;47using System;48using System.Diagnostics.Tracing;49{50 {51 static void Main(string[] args)52 {53 EventSource eventSource = TestPlatformEventSource.Instance;54 EventListener eventListener = new EventListener();55 eventListener.EnableEvents(eventSource, EventLevel.LogAlways, (EventKeywords)0x0000000000000001);
DiscoveryStart
Using AI Code Generation
1using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Tracing;2{3 {4 static void Main(string[] args)5 {6 TestPlatformEventSource.Instance.DiscoveryStart();7 }8 }9}10using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Tracing;11{12 {13 static void Main(string[] args)14 {15 TestPlatformEventSource.Instance.DiscoveryStart();16 }17 }18}19using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Tracing;20{21 {22 static void Main(string[] args)23 {24 TestPlatformEventSource.Instance.DiscoveryStart();25 }26 }27}28using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Tracing;29{30 {31 static void Main(string[] args)32 {33 TestPlatformEventSource.Instance.DiscoveryStart();34 }35 }36}37using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Tracing;38{39 {40 static void Main(string[] args)41 {42 TestPlatformEventSource.Instance.DiscoveryStart();43 }44 }45}46using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Tracing;47{48 {49 static void Main(string[] args)50 {51 TestPlatformEventSource.Instance.DiscoveryStart();52 }53 }54}55using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Tracing;56{
DiscoveryStart
Using AI Code Generation
1using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Tracing;2TestPlatformEventSource.Instance.DiscoveryStart();3using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Tracing;4TestPlatformEventSource.Instance.DiscoveryStop();5using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Tracing;6TestPlatformEventSource.Instance.ExecutionStart();7using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Tracing;8TestPlatformEventSource.Instance.ExecutionStop();9using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Tracing;10TestPlatformEventSource.Instance.TestSessionStart();11using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Tracing;12TestPlatformEventSource.Instance.TestSessionStop();13using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Tracing;14TestPlatformEventSource.Instance.TestSessionAbort();15using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Tracing;16TestPlatformEventSource.Instance.TestSessionPause();17using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Tracing;18TestPlatformEventSource.Instance.TestSessionResume();19 {20 TestPlatformEventSource.Instance.DiscoveryStart();21 }22 }23}24using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Tracing;25{26 {27 static void Main(string[] args)28 {29 TestPlatformEventSource.Instance.DiscoveryStart();30 }31 }32}33using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Tracing;34{
DiscoveryStart
Using AI Code Generation
1using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Tracing;2{3 {4 static void Main(string[] args)5 {6 TestPlatformEventSource.Instance.DiscoveryStart();7 }8 }9}10using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Tracing;11{12 {13 static void Main(string[] args)14 {15 TestPlatformEventSource.Instance.DiscoveryStart();16 }17 }18}19using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Tracing;20{21 {22 static void Main(string[] args)23 {24 TestPlatformEventSource.Instance.DiscoveryStart();25 }26 }27}28using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Tracing;29{30 {31 static void Main(string[] args)32 {33 TestPlatformEventSource.Instance.DiscoveryStart();34 }35 }36}37using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Tracing;38{39 {40 static void Main(string[] args)41 {42 TestPlatformEventSource.Instance.DiscoveryStart();43 }44 }45}46using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Tracing;47{48 {49 static void Main(string[] args)50 {51 TestPlatformEventSource.Instance.DiscoveryStart();52 }53 }54}55using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Tracing;56{
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!