diff --git a/scripts/build/TestPlatform.Dependencies.props b/scripts/build/TestPlatform.Dependencies.props index a3510b25d8..654a6c1f38 100644 --- a/scripts/build/TestPlatform.Dependencies.props +++ b/scripts/build/TestPlatform.Dependencies.props @@ -6,8 +6,8 @@ 15.5.0 - 1.3.2 - 1.3.2 + 1.3.1 + 1.3.1 1.0.3-preview 2.3.1 diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Discovery/DiscovererEnumerator.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/Discovery/DiscovererEnumerator.cs index b692e2c311..4ab2a1aa17 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Discovery/DiscovererEnumerator.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Discovery/DiscovererEnumerator.cs @@ -25,7 +25,7 @@ namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Discovery using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions; - + using Utilities; using CrossPlatEngineResources = Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Resources.Resources; /// @@ -102,14 +102,10 @@ internal void LoadTests(IDictionary> testExtensionSo Justification = "This methods must invoke all possible discoverers and not fail or crash in any one.")] private void LoadTestsFromAnExtension(string extensionAssembly, IEnumerable sources, IRunSettings settings, string testCaseFilter, IMessageLogger logger) { - double totalAdaptersUsed = 0; - // Stopwatch to collect metrics var timeStart = DateTime.UtcNow; - var discoverersFromDeprecatedLocations = false; - - var discovererToSourcesMap = GetDiscovererToSourcesMap(extensionAssembly, sources, logger, this.assemblyProperties); + var discovererToSourcesMap = DiscovererEnumerator.GetDiscovererToSourcesMap(extensionAssembly, sources, logger, this.assemblyProperties); var totalAdapterLoadTIme = DateTime.UtcNow - timeStart; // Collecting Data Point for TimeTaken to Load Adapters @@ -132,98 +128,167 @@ private void LoadTestsFromAnExtension(string extensionAssembly, IEnumerable discoverer, + Dictionary, IEnumerable> discovererToSourcesMap, + DiscoveryContext context, + TestCaseDiscoverySink discoverySink, + IMessageLogger logger, + ref double totalAdaptersUsed, + ref double totalTimeTakenByAdapters) + { + if (DiscovererEnumerator.TryToLoadDiscoverer(discoverer, logger, out var discovererType) == false) + { + // Fail to instantiate the discoverer type. + return; + } + + // on instantiated successfully, get tests + try + { + EqtTrace.Verbose( + "DiscovererEnumerator.DiscoverTestsFromSingleDiscoverer: Loading tests for {0}", + discoverer.Value.GetType().FullName); + + var currentTotalTests = this.discoveryResultCache.TotalDiscoveredTests; + var newTimeStart = DateTime.UtcNow; + + this.testPlatformEventSource.AdapterDiscoveryStart(discoverer.Metadata.DefaultExecutorUri.AbsoluteUri); + discoverer.Value.DiscoverTests(discovererToSourcesMap[discoverer], context, logger, discoverySink); + + var totalAdapterRunTime = DateTime.UtcNow - newTimeStart; + + this.testPlatformEventSource.AdapterDiscoveryStop(this.discoveryResultCache.TotalDiscoveredTests - + currentTotalTests); + + // Record Total Tests Discovered By each Discoverer. + var totalTestsDiscoveredByCurrentDiscoverer = this.discoveryResultCache.TotalDiscoveredTests - currentTotalTests; + this.requestData.MetricsCollection.Add( + string.Format("{0}.{1}", TelemetryDataConstants.TotalTestsByAdapter, + discoverer.Metadata.DefaultExecutorUri), totalTestsDiscoveredByCurrentDiscoverer); + + totalAdaptersUsed++; + + + EqtTrace.Verbose("DiscovererEnumerator.DiscoverTestsFromSingleDiscoverer: Done loading tests for {0}", + discoverer.Value.GetType().FullName); - // if instantiated successfully, get tests - try + var discovererFromDeprecatedLocations = DiscovererEnumerator.IsDiscovererFromDeprecatedLocations(discoverer); + if (discovererFromDeprecatedLocations) { - if (EqtTrace.IsVerboseEnabled) - { - EqtTrace.Verbose( - "DiscoveryContext.LoadTests: Loading tests for {0}", - discoverer.Value.GetType().FullName); - } - - var currentTotalTests = this.discoveryResultCache.TotalDiscoveredTests; - var newTimeStart = DateTime.UtcNow; - - this.testPlatformEventSource.AdapterDiscoveryStart(discoverer.Metadata.DefaultExecutorUri.AbsoluteUri); - discoverer.Value.DiscoverTests(discovererToSourcesMap[discoverer], context, logger, discoverySink); - - var totalAdapterRunTime = DateTime.UtcNow - newTimeStart; - - this.testPlatformEventSource.AdapterDiscoveryStop(this.discoveryResultCache.TotalDiscoveredTests - currentTotalTests); - - // Collecting Total Tests Discovered By each Adapter. - if (this.discoveryResultCache.TotalDiscoveredTests > currentTotalTests) - { - var totalDiscoveredTests = this.discoveryResultCache.TotalDiscoveredTests - currentTotalTests; - this.requestData.MetricsCollection.Add(string.Format("{0}.{1}", TelemetryDataConstants.TotalTestsByAdapter, discoverer.Metadata.DefaultExecutorUri), totalDiscoveredTests); - if (!CrossPlatEngine.Constants.DefaultAdapters.Contains(discoverer.Metadata.DefaultExecutorUri.ToString(), StringComparer.OrdinalIgnoreCase)) - { - var discovererLocation = discoverer.Value.GetType().GetTypeInfo().Assembly.GetAssemblyLocation(); - - discoverersFromDeprecatedLocations |= Path.GetDirectoryName(discovererLocation).Equals(CrossPlatEngine.Constants.DefaultAdapterLocation, StringComparison.OrdinalIgnoreCase); - } - totalAdaptersUsed++; - } - - if (EqtTrace.IsVerboseEnabled) - { - EqtTrace.Verbose( - "DiscoveryContext.LoadTests: Done loading tests for {0}", - discoverer.Value.GetType().FullName); - } - - if (discoverersFromDeprecatedLocations) - { - logger.SendMessage(TestMessageLevel.Warning, string.Format(CultureInfo.CurrentCulture, CrossPlatEngineResources.DeprecatedAdapterPath)); - } - - // Collecting Data Point for Time Taken to Discover Tests by each Adapter - this.requestData.MetricsCollection.Add(string.Format("{0}.{1}", TelemetryDataConstants.TimeTakenToDiscoverTestsByAnAdapter, discoverer.Metadata.DefaultExecutorUri), totalAdapterRunTime.TotalSeconds); - totalTimeTakenByAdapters += totalAdapterRunTime.TotalSeconds; + logger.SendMessage(TestMessageLevel.Warning, + string.Format(CultureInfo.CurrentCulture, CrossPlatEngineResources.DeprecatedAdapterPath)); } - catch (Exception e) - { - var message = string.Format( - CultureInfo.CurrentUICulture, - CrossPlatEngineResources.ExceptionFromLoadTests, - discovererType.Name, - e.Message); - logger.SendMessage(TestMessageLevel.Error, message); - EqtTrace.Error("DiscovererEnumerator.LoadTestsFromAnExtension: {0} ", e); - } + // Collecting Data Point for Time Taken to Discover Tests by each Adapter + this.requestData.MetricsCollection.Add( + string.Format("{0}.{1}", TelemetryDataConstants.TimeTakenToDiscoverTestsByAnAdapter, + discoverer.Metadata.DefaultExecutorUri), totalAdapterRunTime.TotalSeconds); + totalTimeTakenByAdapters += totalAdapterRunTime.TotalSeconds; + } + catch (Exception e) + { + var message = string.Format( + CultureInfo.CurrentUICulture, + CrossPlatEngineResources.ExceptionFromLoadTests, + discovererType.Name, + e.Message); + + logger.SendMessage(TestMessageLevel.Error, message); + EqtTrace.Error("DiscovererEnumerator.DiscoverTestsFromSingleDiscoverer: {0} ", e); } + } - // Collecting Total Time Taken by Adapters - this.requestData.MetricsCollection.Add(TelemetryDataConstants.TimeTakenInSecByAllAdapters, totalTimeTakenByAdapters); + private static bool TryToLoadDiscoverer(LazyExtension discoverer, IMessageLogger logger, out Type discovererType) + { + discovererType = null; - // Collecting Total Adapters Used to Discover tests - this.requestData.MetricsCollection.Add(TelemetryDataConstants.NumberOfAdapterUsedToDiscoverTests, totalAdaptersUsed); + // See if discoverer can be instantiated successfully else move next. + try + { + discovererType = discoverer.Value.GetType(); + } + catch (Exception e) + { + var mesage = string.Format( + CultureInfo.CurrentUICulture, + CrossPlatEngineResources.DiscovererInstantiationException, + e.Message); + logger.SendMessage(TestMessageLevel.Warning, mesage); + EqtTrace.Error("DiscovererEnumerator.LoadTestsFromAnExtension: {0} ", e); + + return false; + } + + return true; } + private static bool IsDiscovererFromDeprecatedLocations( + LazyExtension discoverer) + { + if (CrossPlatEngine.Constants.DefaultAdapters.Contains(discoverer.Metadata.DefaultExecutorUri.ToString(), + StringComparer.OrdinalIgnoreCase)) + { + return false; + } + + var discovererLocation = discoverer.Value.GetType().GetTypeInfo().Assembly.GetAssemblyLocation(); + + return Path.GetDirectoryName(discovererLocation) + .Equals(CrossPlatEngine.Constants.DefaultAdapterLocation, StringComparison.OrdinalIgnoreCase); + } + + private static void LogWarningOnNoTestsDiscovered(IEnumerable sources, string testCaseFilter, IMessageLogger logger) + { + var sourcesString = string.Join(" ", sources); + + // Print warning on no tests. + if (string.IsNullOrEmpty(testCaseFilter) == false) + { + var testCaseFilterToShow = TestCaseFilterDeterminer.ShortenTestCaseFilterIfRequired(testCaseFilter); + + logger.SendMessage( + TestMessageLevel.Warning, + string.Format(CrossPlatEngineResources.NoTestsAvailableForGivenTestCaseFilter, testCaseFilterToShow, sourcesString)); + } + else + { + logger.SendMessage( + TestMessageLevel.Warning, + string.Format( + CultureInfo.CurrentUICulture, + CrossPlatEngineResources.TestRunFailed_NoDiscovererFound_NoTestsAreAvailableInTheSources, + sourcesString)); + } + } + + private void SetAdapterLoggingSettings(IMessageLogger messageLogger, IRunSettings runSettings) { var discoveryMessageLogger = messageLogger as TestSessionMessageLogger; diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Execution/RunTestsWithSources.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/Execution/RunTestsWithSources.cs index d5ff025dd9..3d0308e087 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Execution/RunTestsWithSources.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Execution/RunTestsWithSources.cs @@ -21,7 +21,7 @@ namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Execution using ObjectModel.Client; using ObjectModel.Logging; - + using Utilities; using CrossPlatEngineResources = Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Resources.Resources; internal class RunTestsWithSources : BaseRunTests @@ -62,10 +62,26 @@ protected override void BeforeRaisingTestRunComplete(bool exceptionsHitDuringRun if (!exceptionsHitDuringRunTests && this.executorUriVsSourceList?.Count > 0 && !this.IsCancellationRequested && this.TestRunCache?.TotalExecutedTests <= 0) { - IEnumerable sources = new List(); - var sourcesArray = this.adapterSourceMap.Values.Aggregate(sources, (current, enumerable) => current.Concat(enumerable)).ToArray(); - var sourcesString = string.Join(" ", sourcesArray); + this.LogWarningOnNoTestsExecuted(); + } + } + private void LogWarningOnNoTestsExecuted() + { + IEnumerable sources = new List(); + var sourcesArray = this.adapterSourceMap.Values + .Aggregate(sources, (current, enumerable) => current.Concat(enumerable)).ToArray(); + var sourcesString = string.Join(" ", sourcesArray); + + if (this.TestExecutionContext.TestCaseFilter != null) + { + var testCaseFilterToShow = TestCaseFilterDeterminer.ShortenTestCaseFilterIfRequired(this.TestExecutionContext.TestCaseFilter); + this.TestRunEventsHandler?.HandleLogMessage( + TestMessageLevel.Warning, + string.Format(CrossPlatEngineResources.NoTestsAvailableForGivenTestCaseFilter, testCaseFilterToShow, sourcesString)); + } + else + { this.TestRunEventsHandler?.HandleLogMessage( TestMessageLevel.Warning, string.Format( @@ -170,5 +186,22 @@ private Dictionary, IEnumerable> GetExecutorVsSources return result; } + + private static string TestCaseFilterToShow(string testCaseFilter) + { + var maxTestCaseFilterToShowLength = 63; + string testCaseFilterToShow; + + if (testCaseFilter.Length > maxTestCaseFilterToShowLength) + { + testCaseFilterToShow = testCaseFilter.Substring(0, maxTestCaseFilterToShowLength - 3) + "..."; + } + else + { + testCaseFilterToShow = testCaseFilter; + } + + return testCaseFilterToShow; + } } } diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Execution/RunTestsWithTests.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/Execution/RunTestsWithTests.cs index 0787e30403..b189f37fde 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Execution/RunTestsWithTests.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Execution/RunTestsWithTests.cs @@ -55,7 +55,7 @@ protected override void BeforeRaisingTestRunComplete(bool exceptionsHitDuringRun protected override IEnumerable> GetExecutorUriExtensionMap(IFrameworkHandle testExecutorFrameworkHandle, RunContext runContext) { this.executorUriVsTestList = this.GetExecutorVsTestCaseList(this.testCases); - + Debug.Assert(this.TestExecutionContext.TestCaseFilter == null, "TestCaseFilter should be null for specific tests."); runContext.FilterExpressionWrapper = null; diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Microsoft.TestPlatform.CrossPlatEngine.csproj b/src/Microsoft.TestPlatform.CrossPlatEngine/Microsoft.TestPlatform.CrossPlatEngine.csproj index f91b6c2237..ecb09b0da4 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Microsoft.TestPlatform.CrossPlatEngine.csproj +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Microsoft.TestPlatform.CrossPlatEngine.csproj @@ -11,7 +11,10 @@ - + + ResXFileCodeGenerator + Resources.Designer.cs + diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/Resources.Designer.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/Resources.Designer.cs index 750d15f4c1..ca178642d9 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/Resources.Designer.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/Resources.Designer.cs @@ -78,18 +78,16 @@ internal static string DataCollectorDebuggerWarning { return ResourceManager.GetString("DataCollectorDebuggerWarning", resourceCulture); } } - + /// /// Looks up a localized string similar to Adapter lookup is being changed, please follow https://github.com/Microsoft/vstest-docs/blob/master/RFCs/0022-User-Specified-TestAdapter-Lookup.md#roadmap for more details.. /// - internal static string DeprecatedAdapterPath - { - get - { + internal static string DeprecatedAdapterPath { + get { return ResourceManager.GetString("DeprecatedAdapterPath", resourceCulture); } } - + /// /// Looks up a localized string similar to Exception occurred while instantiating discoverer : {0}. /// @@ -224,7 +222,16 @@ internal static string NonExistingExtensions { return ResourceManager.GetString("NonExistingExtensions", resourceCulture); } } - + + /// + /// Looks up a localized string similar to No test is available for testcase filter `{0}` in {1}. + /// + internal static string NoTestsAvailableForGivenTestCaseFilter { + get { + return ResourceManager.GetString("NoTestsAvailableForGivenTestCaseFilter", resourceCulture); + } + } + /// /// Looks up a localized string similar to None of the specified source(s) '{0}' is valid. Fix the above errors/warnings and then try again. . /// diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/Resources.resx b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/Resources.resx index 63da8ebe38..88fe612fc2 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/Resources.resx +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/Resources.resx @@ -195,4 +195,7 @@ Adapter lookup is being changed, please follow https://github.com/Microsoft/vstest-docs/blob/master/RFCs/0022-User-Specified-TestAdapter-Lookup.md#roadmap for more details. + + No test is available for testcase filter `{0}` in {1} + \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.cs.xlf b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.cs.xlf index d16100d96c..e929d56cc0 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.cs.xlf +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.cs.xlf @@ -1,4 +1,4 @@ - +
@@ -201,6 +201,11 @@ Mění se vyhledávání adaptéru. Další informace najdete tady: https://github.com/Microsoft/vstest-docs/blob/master/RFCs/0022-User-Specified-TestAdapter-Lookup.md#roadmap. + + No test is available for testcase filter `{0}` in {1} + No test is available for testcase filter `{0}` in {1} + + \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.de.xlf b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.de.xlf index c7df3f76b0..bc027690e5 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.de.xlf +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.de.xlf @@ -1,4 +1,4 @@ - +
@@ -201,6 +201,11 @@ Die Adaptersuche wird gerade geändert. Weitere Informationen finden Sie unter https://github.com/Microsoft/vstest-docs/blob/master/RFCs/0022-User-Specified-TestAdapter-Lookup.md#roadmap. + + No test is available for testcase filter `{0}` in {1} + No test is available for testcase filter `{0}` in {1} + + \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.es.xlf b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.es.xlf index 7b5162142b..42edd8b327 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.es.xlf +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.es.xlf @@ -1,4 +1,4 @@ - +
@@ -201,6 +201,11 @@ Se está cambiando la búsqueda de adaptador. Siga https://github.com/Microsoft/vstest-docs/blob/master/RFCs/0022-User-Specified-TestAdapter-Lookup.md#roadmap para obtener más detalles. + + No test is available for testcase filter `{0}` in {1} + No test is available for testcase filter `{0}` in {1} + + \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.fr.xlf b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.fr.xlf index 348f75b3e9..1714095dcd 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.fr.xlf +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.fr.xlf @@ -1,4 +1,4 @@ - +
@@ -201,6 +201,11 @@ La fonctionnalité de recherche d’adaptateur fait actuellement l’objet de modifications. Pour plus d’informations, consultez https://github.com/Microsoft/vstest-docs/blob/master/RFCs/0022-User-Specified-TestAdapter-Lookup.md#roadmap. + + No test is available for testcase filter `{0}` in {1} + No test is available for testcase filter `{0}` in {1} + + \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.it.xlf b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.it.xlf index d08b9e072a..c106a20cee 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.it.xlf +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.it.xlf @@ -1,4 +1,4 @@ - +
@@ -201,6 +201,11 @@ La ricerca degli adattatori verrà modificata a breve. Per maggiori dettagli, vedere https://github.com/Microsoft/vstest-docs/blob/master/RFCs/0022-User-Specified-TestAdapter-Lookup.md#roadmap. + + No test is available for testcase filter `{0}` in {1} + No test is available for testcase filter `{0}` in {1} + + \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.ja.xlf b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.ja.xlf index 3477593ae9..f90575b40b 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.ja.xlf +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.ja.xlf @@ -1,4 +1,4 @@ - +
@@ -201,6 +201,11 @@ アダプター検索は変更中です。詳細については、https://github.com/Microsoft/vstest-docs/blob/master/RFCs/0022-User-Specified-TestAdapter-Lookup.md#roadmap をご覧ください。 + + No test is available for testcase filter `{0}` in {1} + No test is available for testcase filter `{0}` in {1} + + \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.ko.xlf b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.ko.xlf index b38702e4cb..b83419443e 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.ko.xlf +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.ko.xlf @@ -1,4 +1,4 @@ - +
@@ -201,6 +201,11 @@ 어댑터 조회가 변경됩니다. 자세한 내용은 https://github.com/Microsoft/vstest-docs/blob/master/RFCs/0022-User-Specified-TestAdapter-Lookup.md#roadmap을 참조하세요. + + No test is available for testcase filter `{0}` in {1} + No test is available for testcase filter `{0}` in {1} + + \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.pl.xlf b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.pl.xlf index 99c9ecdded..792508ab18 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.pl.xlf +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.pl.xlf @@ -1,4 +1,4 @@ - +
@@ -201,6 +201,11 @@ Wyszukiwanie adaptera jest zmieniane, zobacz https://github.com/Microsoft/vstest-docs/blob/master/RFCs/0022-User-Specified-TestAdapter-Lookup.md#roadmapw celu uzyskania dalszych szczegółów. + + No test is available for testcase filter `{0}` in {1} + No test is available for testcase filter `{0}` in {1} + + \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.pt-BR.xlf b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.pt-BR.xlf index 963e307acd..c05ea2f2f4 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.pt-BR.xlf +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.pt-BR.xlf @@ -1,4 +1,4 @@ - +
@@ -201,6 +201,11 @@ A pesquisa do adaptador está sendo alterada, siga https://github.com/Microsoft/vstest-docs/blob/master/RFCs/0022-User-Specified-TestAdapter-Lookup.md#roadmap para obter mais detalhes. + + No test is available for testcase filter `{0}` in {1} + No test is available for testcase filter `{0}` in {1} + + \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.ru.xlf b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.ru.xlf index 578088bc77..edc8ca876b 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.ru.xlf +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.ru.xlf @@ -1,4 +1,4 @@ - +
@@ -201,6 +201,11 @@ Изменяется поиск адаптеров. Дополнительные сведения: https://github.com/Microsoft/vstest-docs/blob/master/RFCs/0022-User-Specified-TestAdapter-Lookup.md#roadmap. + + No test is available for testcase filter `{0}` in {1} + No test is available for testcase filter `{0}` in {1} + + \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.tr.xlf b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.tr.xlf index b80211e1b5..ad6db44a8a 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.tr.xlf +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.tr.xlf @@ -1,4 +1,4 @@ - +
@@ -201,6 +201,11 @@ Bağdaştırıcı arama değiştiriliyor. Ayrıntılar için lütfen https://github.com/Microsoft/vstest-docs/blob/master/RFCs/0022-User-Specified-TestAdapter-Lookup.md#roadmap sayfasını takip edin. + + No test is available for testcase filter `{0}` in {1} + No test is available for testcase filter `{0}` in {1} + + \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.xlf b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.xlf index 8046023a69..7f5f2b6147 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.xlf +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.xlf @@ -112,6 +112,11 @@ Adapter lookup is being changed, please follow https://github.com/Microsoft/vstest-docs/blob/master/RFCs/0022-User-Specified-TestAdapter-Lookup.md#roadmap for more details. + + No test is available for testcase filter `{0}` in {1} + No test is available for testcase filter `{0}` in {1} + + \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.zh-Hans.xlf b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.zh-Hans.xlf index 7989dd9f02..5cc4be94a2 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.zh-Hans.xlf +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.zh-Hans.xlf @@ -1,4 +1,4 @@ - +
@@ -201,6 +201,11 @@ 适配器查找发生了变化,请转到 https://github.com/Microsoft/vstest-docs/blob/master/RFCs/0022-User-Specified-TestAdapter-Lookup.md#roadmap,了解详细信息。 + + No test is available for testcase filter `{0}` in {1} + No test is available for testcase filter `{0}` in {1} + + \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.zh-Hant.xlf b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.zh-Hant.xlf index eeacc96277..9326bd86bb 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.zh-Hant.xlf +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.zh-Hant.xlf @@ -1,4 +1,4 @@ - +
@@ -201,6 +201,11 @@ 目前正在變更配接器查閱,請遵循 https://github.com/Microsoft/vstest-docs/blob/master/RFCs/0022-User-Specified-TestAdapter-Lookup.md#roadmap,以取得詳細資料。 + + No test is available for testcase filter `{0}` in {1} + No test is available for testcase filter `{0}` in {1} + + \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Utilities/TestCaseFilterDeterminer.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/Utilities/TestCaseFilterDeterminer.cs new file mode 100644 index 0000000000..2d563e77f4 --- /dev/null +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Utilities/TestCaseFilterDeterminer.cs @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Utilities +{ + internal class TestCaseFilterDeterminer + { + private const int MaxLengthOfTestCaseFilterToShow = 256; + + internal static string ShortenTestCaseFilterIfRequired(string testCaseFilter) + { + string shortenTestCaseFilter; + + if (testCaseFilter.Length > MaxLengthOfTestCaseFilterToShow) + { + shortenTestCaseFilter = testCaseFilter.Substring(0, MaxLengthOfTestCaseFilterToShow) + "..."; + } + else + { + shortenTestCaseFilter = testCaseFilter; + } + + return shortenTestCaseFilter; + } + } +} diff --git a/src/SettingsMigrator/Resources/xlf/Resources.cs.xlf b/src/SettingsMigrator/Resources/xlf/Resources.cs.xlf index d316046e88..226264f4ef 100644 --- a/src/SettingsMigrator/Resources/xlf/Resources.cs.xlf +++ b/src/SettingsMigrator/Resources/xlf/Resources.cs.xlf @@ -41,13 +41,18 @@ - Valid usage: SettingsMigrator.exe <Full path to testsettings file or runsettings file to be migrated> -Example: SettingsMigrator.exe E:\MyTest\MyTestSettings.testsettings -Example: SettingsMigrator.exe E:\MyTest\MyOldRunSettings.runsettings - Platné použití: SettingsMigrator.exe <kompletní cesta k souboru testsettings nebo runsettings, který se má migrovat> + Valid usage: +SettingsMigrator.exe <Full path to testsettings file or runsettings file to be migrated> +SettingsMigrator.exe <Full path to testsettings file or runsettings file to be migrated> <Full path to runsettings file to be created> +Examples: +SettingsMigrator.exe E:\MyTest\MyTestSettings.testsettings +SettingsMigrator.exe E:\MyTest\MyOldRunSettings.runsettings +SettingsMigrator.exe E:\MyTest\MyTestSettings.testsettings E:\MyTest\MyNewRunSettings.runsettings +SettingsMigrator.exe E:\MyTest\MyOldRunSettings.runsettings E:\MyTest\MyNewRunSettings.runsettings + Platné použití: SettingsMigrator.exe <kompletní cesta k souboru testsettings nebo runsettings, který se má migrovat> Příklad: SettingsMigrator.exe E:\MyTest\MyTestSettings.testsettings Příklad: SettingsMigrator.exe E:\MyTest\MyOldRunSettings.runsettings - + diff --git a/src/SettingsMigrator/Resources/xlf/Resources.de.xlf b/src/SettingsMigrator/Resources/xlf/Resources.de.xlf index 8719eda18c..cdeaa176b0 100644 --- a/src/SettingsMigrator/Resources/xlf/Resources.de.xlf +++ b/src/SettingsMigrator/Resources/xlf/Resources.de.xlf @@ -41,13 +41,18 @@ - Valid usage: SettingsMigrator.exe <Full path to testsettings file or runsettings file to be migrated> -Example: SettingsMigrator.exe E:\MyTest\MyTestSettings.testsettings -Example: SettingsMigrator.exe E:\MyTest\MyOldRunSettings.runsettings - Gültige Syntax: SettingsMigrator.exe <Vollständiger Pfad zur Datei "testsettings" oder "runsettings", die migriert werden soll> + Valid usage: +SettingsMigrator.exe <Full path to testsettings file or runsettings file to be migrated> +SettingsMigrator.exe <Full path to testsettings file or runsettings file to be migrated> <Full path to runsettings file to be created> +Examples: +SettingsMigrator.exe E:\MyTest\MyTestSettings.testsettings +SettingsMigrator.exe E:\MyTest\MyOldRunSettings.runsettings +SettingsMigrator.exe E:\MyTest\MyTestSettings.testsettings E:\MyTest\MyNewRunSettings.runsettings +SettingsMigrator.exe E:\MyTest\MyOldRunSettings.runsettings E:\MyTest\MyNewRunSettings.runsettings + Gültige Syntax: SettingsMigrator.exe <Vollständiger Pfad zur Datei "testsettings" oder "runsettings", die migriert werden soll> Beispiel: SettingsMigrator.exe E:\MyTest\MyTestSettings.testsettings Beispiel: SettingsMigrator.exe E:\MyTest\MyOldRunSettings.runsettings - + diff --git a/src/SettingsMigrator/Resources/xlf/Resources.es.xlf b/src/SettingsMigrator/Resources/xlf/Resources.es.xlf index c373e4167a..7e72e99e31 100644 --- a/src/SettingsMigrator/Resources/xlf/Resources.es.xlf +++ b/src/SettingsMigrator/Resources/xlf/Resources.es.xlf @@ -41,13 +41,18 @@ - Valid usage: SettingsMigrator.exe <Full path to testsettings file or runsettings file to be migrated> -Example: SettingsMigrator.exe E:\MyTest\MyTestSettings.testsettings -Example: SettingsMigrator.exe E:\MyTest\MyOldRunSettings.runsettings - Uso válido: SettingsMigrator.exe <Ruta de acceso completa al archivo testsettings o runsettings que se migrará> + Valid usage: +SettingsMigrator.exe <Full path to testsettings file or runsettings file to be migrated> +SettingsMigrator.exe <Full path to testsettings file or runsettings file to be migrated> <Full path to runsettings file to be created> +Examples: +SettingsMigrator.exe E:\MyTest\MyTestSettings.testsettings +SettingsMigrator.exe E:\MyTest\MyOldRunSettings.runsettings +SettingsMigrator.exe E:\MyTest\MyTestSettings.testsettings E:\MyTest\MyNewRunSettings.runsettings +SettingsMigrator.exe E:\MyTest\MyOldRunSettings.runsettings E:\MyTest\MyNewRunSettings.runsettings + Uso válido: SettingsMigrator.exe <Ruta de acceso completa al archivo testsettings o runsettings que se migrará> Ejemplo: SettingsMigrator.exe E:\MyTest\MyTestSettings.testsettings Ejemplo: SettingsMigrator.exe E:\MyTest\MyOldRunSettings.runsettings - + diff --git a/src/SettingsMigrator/Resources/xlf/Resources.fr.xlf b/src/SettingsMigrator/Resources/xlf/Resources.fr.xlf index c1513e3c59..851798798a 100644 --- a/src/SettingsMigrator/Resources/xlf/Resources.fr.xlf +++ b/src/SettingsMigrator/Resources/xlf/Resources.fr.xlf @@ -41,13 +41,18 @@ - Valid usage: SettingsMigrator.exe <Full path to testsettings file or runsettings file to be migrated> -Example: SettingsMigrator.exe E:\MyTest\MyTestSettings.testsettings -Example: SettingsMigrator.exe E:\MyTest\MyOldRunSettings.runsettings - Utilisation valide : SettingsMigrator.exe <Chemin complet vers le fichier testsettings ou runsettings à migrer> + Valid usage: +SettingsMigrator.exe <Full path to testsettings file or runsettings file to be migrated> +SettingsMigrator.exe <Full path to testsettings file or runsettings file to be migrated> <Full path to runsettings file to be created> +Examples: +SettingsMigrator.exe E:\MyTest\MyTestSettings.testsettings +SettingsMigrator.exe E:\MyTest\MyOldRunSettings.runsettings +SettingsMigrator.exe E:\MyTest\MyTestSettings.testsettings E:\MyTest\MyNewRunSettings.runsettings +SettingsMigrator.exe E:\MyTest\MyOldRunSettings.runsettings E:\MyTest\MyNewRunSettings.runsettings + Utilisation valide : SettingsMigrator.exe <Chemin complet vers le fichier testsettings ou runsettings à migrer> Exemple : SettingsMigrator.exe E:\MyTest\MyTestSettings.testsettings Exemple : SettingsMigrator.exe E:\MyTest\MyOldRunSettings.runsettings - + diff --git a/src/SettingsMigrator/Resources/xlf/Resources.it.xlf b/src/SettingsMigrator/Resources/xlf/Resources.it.xlf index a907991004..6934909180 100644 --- a/src/SettingsMigrator/Resources/xlf/Resources.it.xlf +++ b/src/SettingsMigrator/Resources/xlf/Resources.it.xlf @@ -41,13 +41,18 @@ - Valid usage: SettingsMigrator.exe <Full path to testsettings file or runsettings file to be migrated> -Example: SettingsMigrator.exe E:\MyTest\MyTestSettings.testsettings -Example: SettingsMigrator.exe E:\MyTest\MyOldRunSettings.runsettings - Sintassi valida: SettingsMigrator.exe <percorso completo del file testsettings o del file runsettings di cui eseguire la migrazione> + Valid usage: +SettingsMigrator.exe <Full path to testsettings file or runsettings file to be migrated> +SettingsMigrator.exe <Full path to testsettings file or runsettings file to be migrated> <Full path to runsettings file to be created> +Examples: +SettingsMigrator.exe E:\MyTest\MyTestSettings.testsettings +SettingsMigrator.exe E:\MyTest\MyOldRunSettings.runsettings +SettingsMigrator.exe E:\MyTest\MyTestSettings.testsettings E:\MyTest\MyNewRunSettings.runsettings +SettingsMigrator.exe E:\MyTest\MyOldRunSettings.runsettings E:\MyTest\MyNewRunSettings.runsettings + Sintassi valida: SettingsMigrator.exe <percorso completo del file testsettings o del file runsettings di cui eseguire la migrazione> Esempio: SettingsMigrator.exe E:\MyTest\MyTestSettings.testsettings Esempio: SettingsMigrator.exe E:\MyTest\MyOldRunSettings.runsettings - + diff --git a/src/SettingsMigrator/Resources/xlf/Resources.ja.xlf b/src/SettingsMigrator/Resources/xlf/Resources.ja.xlf index ed7b25909e..2629b37732 100644 --- a/src/SettingsMigrator/Resources/xlf/Resources.ja.xlf +++ b/src/SettingsMigrator/Resources/xlf/Resources.ja.xlf @@ -41,13 +41,18 @@ - Valid usage: SettingsMigrator.exe <Full path to testsettings file or runsettings file to be migrated> -Example: SettingsMigrator.exe E:\MyTest\MyTestSettings.testsettings -Example: SettingsMigrator.exe E:\MyTest\MyOldRunSettings.runsettings - 有効な使用法: SettingsMigrator.exe <移行する testsettings ファイルまたは runsettings ファイルの完全なパス> + Valid usage: +SettingsMigrator.exe <Full path to testsettings file or runsettings file to be migrated> +SettingsMigrator.exe <Full path to testsettings file or runsettings file to be migrated> <Full path to runsettings file to be created> +Examples: +SettingsMigrator.exe E:\MyTest\MyTestSettings.testsettings +SettingsMigrator.exe E:\MyTest\MyOldRunSettings.runsettings +SettingsMigrator.exe E:\MyTest\MyTestSettings.testsettings E:\MyTest\MyNewRunSettings.runsettings +SettingsMigrator.exe E:\MyTest\MyOldRunSettings.runsettings E:\MyTest\MyNewRunSettings.runsettings + 有効な使用法: SettingsMigrator.exe <移行する testsettings ファイルまたは runsettings ファイルの完全なパス> 例: SettingsMigrator.exe E:\MyTest\MyTestSettings.testsettings 例: SettingsMigrator.exe E:\MyTest\MyOldRunSettings.runsettings - + diff --git a/src/SettingsMigrator/Resources/xlf/Resources.ko.xlf b/src/SettingsMigrator/Resources/xlf/Resources.ko.xlf index a632dabdaf..1ab7228577 100644 --- a/src/SettingsMigrator/Resources/xlf/Resources.ko.xlf +++ b/src/SettingsMigrator/Resources/xlf/Resources.ko.xlf @@ -41,13 +41,18 @@ - Valid usage: SettingsMigrator.exe <Full path to testsettings file or runsettings file to be migrated> -Example: SettingsMigrator.exe E:\MyTest\MyTestSettings.testsettings -Example: SettingsMigrator.exe E:\MyTest\MyOldRunSettings.runsettings - 유효한 사용: SettingsMigrator.exe <마이그레이션할 testsettings 파일 또는 runsettings 파일의 전체 경로> + Valid usage: +SettingsMigrator.exe <Full path to testsettings file or runsettings file to be migrated> +SettingsMigrator.exe <Full path to testsettings file or runsettings file to be migrated> <Full path to runsettings file to be created> +Examples: +SettingsMigrator.exe E:\MyTest\MyTestSettings.testsettings +SettingsMigrator.exe E:\MyTest\MyOldRunSettings.runsettings +SettingsMigrator.exe E:\MyTest\MyTestSettings.testsettings E:\MyTest\MyNewRunSettings.runsettings +SettingsMigrator.exe E:\MyTest\MyOldRunSettings.runsettings E:\MyTest\MyNewRunSettings.runsettings + 유효한 사용: SettingsMigrator.exe <마이그레이션할 testsettings 파일 또는 runsettings 파일의 전체 경로> Example: SettingsMigrator.exe E:\MyTest\MyTestSettings.testsettings Example: SettingsMigrator.exe E:\MyTest\MyOldRunSettings.runsettings - + diff --git a/src/SettingsMigrator/Resources/xlf/Resources.pl.xlf b/src/SettingsMigrator/Resources/xlf/Resources.pl.xlf index 6eb9ae79dd..a3885ef43b 100644 --- a/src/SettingsMigrator/Resources/xlf/Resources.pl.xlf +++ b/src/SettingsMigrator/Resources/xlf/Resources.pl.xlf @@ -41,13 +41,18 @@ - Valid usage: SettingsMigrator.exe <Full path to testsettings file or runsettings file to be migrated> -Example: SettingsMigrator.exe E:\MyTest\MyTestSettings.testsettings -Example: SettingsMigrator.exe E:\MyTest\MyOldRunSettings.runsettings - Prawidłowe użycie: SettingsMigrator.exe <pełna ścieżka do pliku testsettings lub runsettings do zmigrowania> + Valid usage: +SettingsMigrator.exe <Full path to testsettings file or runsettings file to be migrated> +SettingsMigrator.exe <Full path to testsettings file or runsettings file to be migrated> <Full path to runsettings file to be created> +Examples: +SettingsMigrator.exe E:\MyTest\MyTestSettings.testsettings +SettingsMigrator.exe E:\MyTest\MyOldRunSettings.runsettings +SettingsMigrator.exe E:\MyTest\MyTestSettings.testsettings E:\MyTest\MyNewRunSettings.runsettings +SettingsMigrator.exe E:\MyTest\MyOldRunSettings.runsettings E:\MyTest\MyNewRunSettings.runsettings + Prawidłowe użycie: SettingsMigrator.exe <pełna ścieżka do pliku testsettings lub runsettings do zmigrowania> Przykład: SettingsMigrator.exe E:\MyTest\MyTestSettings.testsettings Przykład: SettingsMigrator.exe E:\MyTest\MyOldRunSettings.runsettings - + diff --git a/src/SettingsMigrator/Resources/xlf/Resources.pt-BR.xlf b/src/SettingsMigrator/Resources/xlf/Resources.pt-BR.xlf index 5ae38e5818..8a2c60f07f 100644 --- a/src/SettingsMigrator/Resources/xlf/Resources.pt-BR.xlf +++ b/src/SettingsMigrator/Resources/xlf/Resources.pt-BR.xlf @@ -41,13 +41,18 @@ - Valid usage: SettingsMigrator.exe <Full path to testsettings file or runsettings file to be migrated> -Example: SettingsMigrator.exe E:\MyTest\MyTestSettings.testsettings -Example: SettingsMigrator.exe E:\MyTest\MyOldRunSettings.runsettings - Uso válido: SettingsMigrator.exe <Caminho completo para o arquivo testsettings ou o arquivo runsettings será migrado> + Valid usage: +SettingsMigrator.exe <Full path to testsettings file or runsettings file to be migrated> +SettingsMigrator.exe <Full path to testsettings file or runsettings file to be migrated> <Full path to runsettings file to be created> +Examples: +SettingsMigrator.exe E:\MyTest\MyTestSettings.testsettings +SettingsMigrator.exe E:\MyTest\MyOldRunSettings.runsettings +SettingsMigrator.exe E:\MyTest\MyTestSettings.testsettings E:\MyTest\MyNewRunSettings.runsettings +SettingsMigrator.exe E:\MyTest\MyOldRunSettings.runsettings E:\MyTest\MyNewRunSettings.runsettings + Uso válido: SettingsMigrator.exe <Caminho completo para o arquivo testsettings ou o arquivo runsettings será migrado> Exemplo: SettingsMigrator.exe E:\MyTest\MyTestSettings.testsettings Exemplo: SettingsMigrator.exe E:\MyTest\MyOldRunSettings.runsettings - + diff --git a/src/SettingsMigrator/Resources/xlf/Resources.ru.xlf b/src/SettingsMigrator/Resources/xlf/Resources.ru.xlf index 07bb2e9ff2..b6c6ee1971 100644 --- a/src/SettingsMigrator/Resources/xlf/Resources.ru.xlf +++ b/src/SettingsMigrator/Resources/xlf/Resources.ru.xlf @@ -41,13 +41,18 @@ - Valid usage: SettingsMigrator.exe <Full path to testsettings file or runsettings file to be migrated> -Example: SettingsMigrator.exe E:\MyTest\MyTestSettings.testsettings -Example: SettingsMigrator.exe E:\MyTest\MyOldRunSettings.runsettings - Допустимое использование: SettingsMigrator.exe <Полный путь к переносимому файлу testsettings или runsettings> + Valid usage: +SettingsMigrator.exe <Full path to testsettings file or runsettings file to be migrated> +SettingsMigrator.exe <Full path to testsettings file or runsettings file to be migrated> <Full path to runsettings file to be created> +Examples: +SettingsMigrator.exe E:\MyTest\MyTestSettings.testsettings +SettingsMigrator.exe E:\MyTest\MyOldRunSettings.runsettings +SettingsMigrator.exe E:\MyTest\MyTestSettings.testsettings E:\MyTest\MyNewRunSettings.runsettings +SettingsMigrator.exe E:\MyTest\MyOldRunSettings.runsettings E:\MyTest\MyNewRunSettings.runsettings + Допустимое использование: SettingsMigrator.exe <Полный путь к переносимому файлу testsettings или runsettings> Пример: SettingsMigrator.exe E:\MyTest\MyTestSettings.testsettings Пример: SettingsMigrator.exe E:\MyTest\MyOldRunSettings.runsettings - + diff --git a/src/SettingsMigrator/Resources/xlf/Resources.tr.xlf b/src/SettingsMigrator/Resources/xlf/Resources.tr.xlf index c64fbbe738..fae4ee2ab5 100644 --- a/src/SettingsMigrator/Resources/xlf/Resources.tr.xlf +++ b/src/SettingsMigrator/Resources/xlf/Resources.tr.xlf @@ -41,13 +41,18 @@ - Valid usage: SettingsMigrator.exe <Full path to testsettings file or runsettings file to be migrated> -Example: SettingsMigrator.exe E:\MyTest\MyTestSettings.testsettings -Example: SettingsMigrator.exe E:\MyTest\MyOldRunSettings.runsettings - Geçerli kullanım: SettingsMigrator.exe <Geçirilecek testsettings dosyasının veya runsettings dosyasının tam yolu> + Valid usage: +SettingsMigrator.exe <Full path to testsettings file or runsettings file to be migrated> +SettingsMigrator.exe <Full path to testsettings file or runsettings file to be migrated> <Full path to runsettings file to be created> +Examples: +SettingsMigrator.exe E:\MyTest\MyTestSettings.testsettings +SettingsMigrator.exe E:\MyTest\MyOldRunSettings.runsettings +SettingsMigrator.exe E:\MyTest\MyTestSettings.testsettings E:\MyTest\MyNewRunSettings.runsettings +SettingsMigrator.exe E:\MyTest\MyOldRunSettings.runsettings E:\MyTest\MyNewRunSettings.runsettings + Geçerli kullanım: SettingsMigrator.exe <Geçirilecek testsettings dosyasının veya runsettings dosyasının tam yolu> Örnek: SettingsMigrator.exe E:\MyTest\MyTestSettings.testsettings Örnek: SettingsMigrator.exe E:\MyTest\MyOldRunSettings.runsettings - + diff --git a/src/SettingsMigrator/Resources/xlf/Resources.zh-Hans.xlf b/src/SettingsMigrator/Resources/xlf/Resources.zh-Hans.xlf index d5553cb1cb..59f74dc056 100644 --- a/src/SettingsMigrator/Resources/xlf/Resources.zh-Hans.xlf +++ b/src/SettingsMigrator/Resources/xlf/Resources.zh-Hans.xlf @@ -41,13 +41,18 @@ - Valid usage: SettingsMigrator.exe <Full path to testsettings file or runsettings file to be migrated> -Example: SettingsMigrator.exe E:\MyTest\MyTestSettings.testsettings -Example: SettingsMigrator.exe E:\MyTest\MyOldRunSettings.runsettings - 有效用法: SettingsMigrator.exe <要迁移的 testsettings 文件或 runsettings 文件的完整路径> + Valid usage: +SettingsMigrator.exe <Full path to testsettings file or runsettings file to be migrated> +SettingsMigrator.exe <Full path to testsettings file or runsettings file to be migrated> <Full path to runsettings file to be created> +Examples: +SettingsMigrator.exe E:\MyTest\MyTestSettings.testsettings +SettingsMigrator.exe E:\MyTest\MyOldRunSettings.runsettings +SettingsMigrator.exe E:\MyTest\MyTestSettings.testsettings E:\MyTest\MyNewRunSettings.runsettings +SettingsMigrator.exe E:\MyTest\MyOldRunSettings.runsettings E:\MyTest\MyNewRunSettings.runsettings + 有效用法: SettingsMigrator.exe <要迁移的 testsettings 文件或 runsettings 文件的完整路径> 示例: SettingsMigrator.exe E:\MyTest\MyTestSettings.testsettings Example: SettingsMigrator.exe E:\MyTest\MyOldRunSettings.runsettings - + diff --git a/src/SettingsMigrator/Resources/xlf/Resources.zh-Hant.xlf b/src/SettingsMigrator/Resources/xlf/Resources.zh-Hant.xlf index 976aac0238..6d3802b669 100644 --- a/src/SettingsMigrator/Resources/xlf/Resources.zh-Hant.xlf +++ b/src/SettingsMigrator/Resources/xlf/Resources.zh-Hant.xlf @@ -41,13 +41,18 @@ - Valid usage: SettingsMigrator.exe <Full path to testsettings file or runsettings file to be migrated> -Example: SettingsMigrator.exe E:\MyTest\MyTestSettings.testsettings -Example: SettingsMigrator.exe E:\MyTest\MyOldRunSettings.runsettings - 有效用法: SettingsMigrator.exe <到達 testsettings 檔案或要移轉之 runsettings 檔案的完整路徑> + Valid usage: +SettingsMigrator.exe <Full path to testsettings file or runsettings file to be migrated> +SettingsMigrator.exe <Full path to testsettings file or runsettings file to be migrated> <Full path to runsettings file to be created> +Examples: +SettingsMigrator.exe E:\MyTest\MyTestSettings.testsettings +SettingsMigrator.exe E:\MyTest\MyOldRunSettings.runsettings +SettingsMigrator.exe E:\MyTest\MyTestSettings.testsettings E:\MyTest\MyNewRunSettings.runsettings +SettingsMigrator.exe E:\MyTest\MyOldRunSettings.runsettings E:\MyTest\MyNewRunSettings.runsettings + 有效用法: SettingsMigrator.exe <到達 testsettings 檔案或要移轉之 runsettings 檔案的完整路徑> 範例: SettingsMigrator.exe E:\MyTest\MyTestSettings.testsettings 範例: SettingsMigrator.exe E:\MyTest\MyOldRunSettings.runsettings - + diff --git a/src/vstest.console/Internal/ConsoleLogger.cs b/src/vstest.console/Internal/ConsoleLogger.cs index 6b7f8336f7..a6e2149ace 100644 --- a/src/vstest.console/Internal/ConsoleLogger.cs +++ b/src/vstest.console/Internal/ConsoleLogger.cs @@ -147,6 +147,12 @@ public void Initialize(TestLoggerEvents events, string testRunDirectory) events.TestRunMessage += this.TestMessageHandler; events.TestResult += this.TestResultHandler; events.TestRunComplete += this.TestRunCompleteHandler; + + // Register for the discovery events. + events.DiscoveryMessage += this.TestMessageHandler; + + // TODO Get changes from https://github.com/Microsoft/vstest/pull/1111/ + // events.DiscoveredTests += DiscoveredTestsHandler; } public void Initialize(TestLoggerEvents events, Dictionary parameters) diff --git a/src/vstest.console/Processors/RunTestsArgumentProcessor.cs b/src/vstest.console/Processors/RunTestsArgumentProcessor.cs index 265b230568..ed8ffcbe33 100644 --- a/src/vstest.console/Processors/RunTestsArgumentProcessor.cs +++ b/src/vstest.console/Processors/RunTestsArgumentProcessor.cs @@ -129,7 +129,7 @@ public RunTestsArgumentExecutor( this.runSettingsManager = runSettingsProvider; this.testRequestManager = testRequestManager; this.output = output; - this.testRunEventsRegistrar = new TestRunRequestEventsRegistrar(this.output); + this.testRunEventsRegistrar = new TestRunRequestEventsRegistrar(this.output, this.commandLineOptions); } #endregion @@ -206,10 +206,12 @@ private void RunTests(IEnumerable sources) private class TestRunRequestEventsRegistrar : ITestRunEventsRegistrar { private IOutput output; + private CommandLineOptions commandLineOptions; - public TestRunRequestEventsRegistrar(IOutput output) + public TestRunRequestEventsRegistrar(IOutput output, CommandLineOptions commandLineOptions) { this.output = output; + this.commandLineOptions = commandLineOptions; } public void RegisterTestRunEvents(ITestRunRequest testRunRequest) @@ -236,7 +238,7 @@ private void TestRunRequest_OnRunCompletion(object sender, TestRunCompleteEventA var testsFoundInAnySource = (e.TestRunStatistics == null) ? false : (e.TestRunStatistics.ExecutedTests > 0); // Indicate the user to use testadapterpath command if there are no tests found - if (!testsFoundInAnySource && string.IsNullOrEmpty(CommandLineOptions.Instance.TestAdapterPath)) + if (!testsFoundInAnySource && string.IsNullOrEmpty(CommandLineOptions.Instance.TestAdapterPath) && this.commandLineOptions.TestCaseFilterValue == null) { this.output.Warning(false, CommandLineResources.SuggestTestAdapterPathIfNoTestsIsFound); } diff --git a/test/Microsoft.TestPlatform.AcceptanceTests/DiscoveryTests.cs b/test/Microsoft.TestPlatform.AcceptanceTests/DiscoveryTests.cs index 3bec23d458..5c451c10e6 100644 --- a/test/Microsoft.TestPlatform.AcceptanceTests/DiscoveryTests.cs +++ b/test/Microsoft.TestPlatform.AcceptanceTests/DiscoveryTests.cs @@ -69,5 +69,26 @@ public void DiscoverFullyQualifiedTests(RunnerInfo runnerInfo) File.Delete(this.dummyFilePath); } } + + [TestMethod] + [NetFullTargetFrameworkDataSource] + [NetCoreTargetFrameworkDataSource] + public void DiscoverTestsShouldShowProperWarningIfNoTestsOnTestCaseFilter(RunnerInfo runnerInfo) + { + AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); + + var assetFullPath = this.GetAssetFullPath("SimpleTestProject2.dll"); + var arguments = PrepareArguments(assetFullPath, this.GetTestAdapterPath(), string.Empty, this.FrameworkArgValue, this.testEnvironment.InIsolationValue); + arguments = string.Concat(arguments, " /listtests" ); + arguments = string.Concat(arguments, " /testcasefilter:NonExistTestCaseName"); + arguments = string.Concat(arguments, " /logger:\"console;prefix=true\""); + this.InvokeVsTest(arguments); + + StringAssert.Contains(this.StdOut, "Warning: No test is available for testcase filter `NonExistTestCaseName` in"); + + StringAssert.Contains(this.StdOut, "SimpleTestProject2.dll"); + + this.ExitCodeEquals(0); + } } } diff --git a/test/Microsoft.TestPlatform.AcceptanceTests/TranslationLayerTests/RunTests.cs b/test/Microsoft.TestPlatform.AcceptanceTests/TranslationLayerTests/RunTests.cs index c15bd8b8d4..a71813a897 100644 --- a/test/Microsoft.TestPlatform.AcceptanceTests/TranslationLayerTests/RunTests.cs +++ b/test/Microsoft.TestPlatform.AcceptanceTests/TranslationLayerTests/RunTests.cs @@ -13,6 +13,7 @@ namespace Microsoft.TestPlatform.AcceptanceTests.TranslationLayerTests using Microsoft.VisualStudio.TestPlatform.ObjectModel; using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; using Microsoft.VisualStudio.TestTools.UnitTesting; + using VisualStudio.TestPlatform.ObjectModel.Logging; /// /// The Run Tests using VsTestConsoleWrapper API's @@ -139,6 +140,39 @@ public void RunTestsShouldThrowOnStackOverflowException(RunnerInfo runnerInfo) Assert.AreEqual(errorMessage, this.runEventHandler.LogMessage); } + [TestMethod] + [NetFullTargetFrameworkDataSource(useCoreRunner: false)] + [NetCoreTargetFrameworkDataSource(useCoreRunner: false)] + public void RunTestsShouldShowProperWarningOnNoTestsForTestCaseFilter(RunnerInfo runnerInfo) + { + AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); + this.Setup(); + + var testAssemblyName = "SimpleTestProject2.dll"; + var source = new List() {this.GetAssetFullPath(testAssemblyName)}; + + var veryLongTestCaseFilter = + "FullyQualifiedName=VeryLongTestCaseNameeeeeeeeeeeeee" + + "eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee" + + "eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee" + + "eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee" + + "eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"; + + this.vstestConsoleWrapper.RunTests( + source, + this.GetDefaultRunSettings(), + new TestPlatformOptions() { TestCaseFilter = veryLongTestCaseFilter }, + this.runEventHandler); + + var expectedFilter = veryLongTestCaseFilter.Substring(0, 256) + "..."; + + // Assert + StringAssert.StartsWith(this.runEventHandler.LogMessage, $"No test is available for testcase filter `{expectedFilter}` in"); + StringAssert.EndsWith(this.runEventHandler.LogMessage, testAssemblyName); + + Assert.AreEqual(TestMessageLevel.Warning , this.runEventHandler.TestMessageLevel); + } + private IList GetTestAssemblies() { var testAssemblies = new List diff --git a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Discovery/DiscovererEnumeratorTests.cs b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Discovery/DiscovererEnumeratorTests.cs index 740646dc7d..13bc8b7075 100644 --- a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Discovery/DiscovererEnumeratorTests.cs +++ b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Discovery/DiscovererEnumeratorTests.cs @@ -10,8 +10,8 @@ namespace TestPlatform.CrossPlatEngine.UnitTests.Discovery using System.Linq; using System.Reflection; - using Microsoft.VisualStudio.TestPlatform.Common.Interfaces; using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework; + using Microsoft.VisualStudio.TestPlatform.Common.Interfaces; using Microsoft.VisualStudio.TestPlatform.Common.Telemetry; using Microsoft.VisualStudio.TestPlatform.Common.Utilities; using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Tracing.Interfaces; @@ -35,9 +35,10 @@ public class DiscovererEnumeratorTests private Mock mockRequestData; private Mock mockMetricsCollection; private Mock mockAssemblyProperties; + private Mock runSettingsMock; + private Mock messageLoggerMock; - [TestInitialize] - public void TestInit() + public DiscovererEnumeratorTests() { this.mockTestPlatformEventSource = new Mock(); this.discoveryResultCache = new DiscoveryResultCache(1000, TimeSpan.FromHours(1), (tests) => { }); @@ -46,10 +47,22 @@ public void TestInit() this.mockAssemblyProperties = new Mock(); this.mockRequestData.Setup(rd => rd.MetricsCollection).Returns(this.mockMetricsCollection.Object); this.discovererEnumerator = new DiscovererEnumerator(this.mockRequestData.Object, this.discoveryResultCache, this.mockTestPlatformEventSource.Object, this.mockAssemblyProperties.Object); - + this.runSettingsMock = new Mock(); + this.messageLoggerMock = new Mock(); + TestPluginCacheTests.SetupMockExtensions( new string[] { typeof(DiscovererEnumeratorTests).GetTypeInfo().Assembly.Location }, + () => { }); TestDiscoveryExtensionManager.Destroy(); } + [TestCleanup] + public void Cleanup() + { + ManagedDllTestDiscoverer.Reset(); + NativeDllTestDiscoverer.Reset(); + JsonTestDiscoverer.Reset(); + NotImplementedTestDiscoverer.Reset(); + } + [TestMethod] public void LoadTestsShouldReportWarningOnNoDiscoverers() { @@ -57,18 +70,17 @@ public void LoadTestsShouldReportWarningOnNoDiscoverers() new string[] { typeof(TestPluginCache).GetTypeInfo().Assembly.Location }, () => { }); var sources = new List { typeof(DiscoveryResultCacheTests).GetTypeInfo().Assembly.Location }; - var mockLogger = new Mock(); var extensionSourceMap = new Dictionary>(); extensionSourceMap.Add("_none_", sources); - this.discovererEnumerator.LoadTests(extensionSourceMap, new Mock().Object, null, mockLogger.Object); + this.discovererEnumerator.LoadTests(extensionSourceMap, this.runSettingsMock.Object, null, this.messageLoggerMock.Object); var messageFormat = "No test is available in {0}. Make sure that test discoverer & executors are registered and platform & framework version settings are appropriate and try again."; var message = string.Format(messageFormat, string.Join(" ", sources)); - mockLogger.Verify( + this.messageLoggerMock.Verify( l => l.SendMessage(TestMessageLevel.Warning, message), Times.Once); } @@ -84,491 +96,441 @@ public void LoadTestsShouldNotCallIntoDiscoverersIfNoneMatchesSources() var extensionSourceMap = new Dictionary>(); extensionSourceMap.Add("_none_", sources); - this.discovererEnumerator.LoadTests(extensionSourceMap, new Mock().Object, null, new Mock().Object); + this.discovererEnumerator.LoadTests(extensionSourceMap, this.runSettingsMock.Object, null, this.messageLoggerMock.Object); Assert.IsFalse(ManagedDllTestDiscoverer.IsManagedDiscoverTestCalled); Assert.IsFalse(NativeDllTestDiscoverer.IsNativeDiscoverTestCalled); - - this.ResetDiscoverers(); } [TestMethod] public void LoadTestsShouldCallOnlyNativeDiscovererIfNativeAssembliesPassed() { - try - { - TestPluginCacheTests.SetupMockExtensions( - new string[] { typeof(DiscovererEnumeratorTests).GetTypeInfo().Assembly.Location }, - () => { }); + TestPluginCacheTests.SetupMockExtensions( + new string[] { typeof(DiscovererEnumeratorTests).GetTypeInfo().Assembly.Location }, + () => { }); - mockAssemblyProperties.Setup(pe => pe.GetAssemblyType("native.dll")).Returns(AssemblyType.Native); + this.mockAssemblyProperties.Setup(pe => pe.GetAssemblyType("native.dll")).Returns(AssemblyType.Native); - var sources = new List - { - "native.dll" - }; + var sources = new List + { + "native.dll" + }; - var extensionSourceMap = new Dictionary>(); - extensionSourceMap.Add("_none_", sources); + var extensionSourceMap = new Dictionary>(); + extensionSourceMap.Add("_none_", sources); - var settings = new Mock().Object; - var logger = new Mock().Object; - string testCaseFilter = "TestFilter"; + string testCaseFilter = "TestFilter"; - this.discovererEnumerator.LoadTests(extensionSourceMap, settings, testCaseFilter, logger); + this.discovererEnumerator.LoadTests(extensionSourceMap, this.runSettingsMock.Object, testCaseFilter, this.messageLoggerMock.Object); - Assert.IsTrue(NativeDllTestDiscoverer.IsNativeDiscoverTestCalled); - CollectionAssert.AreEqual(sources, NativeDllTestDiscoverer.Sources.ToList()); + Assert.IsTrue(NativeDllTestDiscoverer.IsNativeDiscoverTestCalled); + CollectionAssert.AreEqual(sources, NativeDllTestDiscoverer.Sources.ToList()); - Assert.IsFalse(ManagedDllTestDiscoverer.IsManagedDiscoverTestCalled); - Assert.IsFalse(JsonTestDiscoverer.IsDiscoverTestCalled); - } - finally - { - this.ResetDiscoverers(); - } + Assert.IsFalse(ManagedDllTestDiscoverer.IsManagedDiscoverTestCalled); + Assert.IsFalse(JsonTestDiscoverer.IsDiscoverTestCalled); } [TestMethod] public void LoadTestsShouldCallOnlyManagedDiscovererIfManagedAssembliesPassed() { - try - { - TestPluginCacheTests.SetupMockExtensions( - new string[] { typeof(DiscovererEnumeratorTests).GetTypeInfo().Assembly.Location }, - () => { }); + TestPluginCacheTests.SetupMockExtensions( + new string[] { typeof(DiscovererEnumeratorTests).GetTypeInfo().Assembly.Location }, + () => { }); - mockAssemblyProperties.Setup(pe => pe.GetAssemblyType("managed.dll")).Returns(AssemblyType.Managed); + this.mockAssemblyProperties.Setup(pe => pe.GetAssemblyType("managed.dll")).Returns(AssemblyType.Managed); - var sources = new List - { - "managed.dll" - }; + var sources = new List + { + "managed.dll" + }; - var extensionSourceMap = new Dictionary>(); - extensionSourceMap.Add("_none_", sources); + var extensionSourceMap = new Dictionary>(); + extensionSourceMap.Add("_none_", sources); - var settings = new Mock().Object; - var logger = new Mock().Object; - string testCaseFilter = "TestFilter"; + string testCaseFilter = "TestFilter"; - this.discovererEnumerator.LoadTests(extensionSourceMap, settings, testCaseFilter, logger); + this.discovererEnumerator.LoadTests(extensionSourceMap, this.runSettingsMock.Object, testCaseFilter, this.messageLoggerMock.Object); - Assert.IsTrue(ManagedDllTestDiscoverer.IsManagedDiscoverTestCalled); - CollectionAssert.AreEqual(sources, ManagedDllTestDiscoverer.Sources.ToList()); + Assert.IsTrue(ManagedDllTestDiscoverer.IsManagedDiscoverTestCalled); + CollectionAssert.AreEqual(sources, ManagedDllTestDiscoverer.Sources.ToList()); - Assert.IsFalse(NativeDllTestDiscoverer.IsNativeDiscoverTestCalled); - Assert.IsFalse(JsonTestDiscoverer.IsDiscoverTestCalled); - } - finally - { - this.ResetDiscoverers(); - } + Assert.IsFalse(NativeDllTestDiscoverer.IsNativeDiscoverTestCalled); + Assert.IsFalse(JsonTestDiscoverer.IsDiscoverTestCalled); } [TestMethod] public void LoadTestsShouldCallBothNativeAndManagedDiscoverersWithCorrectSources() { - try - { - TestPluginCacheTests.SetupMockExtensions( - new string[] { typeof(DiscovererEnumeratorTests).GetTypeInfo().Assembly.Location }, - () => { }); + TestPluginCacheTests.SetupMockExtensions( + new string[] { typeof(DiscovererEnumeratorTests).GetTypeInfo().Assembly.Location }, + () => { }); - mockAssemblyProperties.Setup(pe => pe.GetAssemblyType("native.dll")).Returns(AssemblyType.Native); - mockAssemblyProperties.Setup(pe => pe.GetAssemblyType("managed.dll")).Returns(AssemblyType.Managed); + this.mockAssemblyProperties.Setup(pe => pe.GetAssemblyType("native.dll")).Returns(AssemblyType.Native); + this.mockAssemblyProperties.Setup(pe => pe.GetAssemblyType("managed.dll")).Returns(AssemblyType.Managed); - var nativeSources = new List - { - "native.dll" - }; - var managedSources = new List - { - "managed.dll" - }; + var nativeSources = new List + { + "native.dll" + }; + var managedSources = new List + { + "managed.dll" + }; - var extensionSourceMap = new Dictionary>(); - extensionSourceMap.Add("_none_", nativeSources.Concat(managedSources)); + var extensionSourceMap = new Dictionary>(); + extensionSourceMap.Add("_none_", nativeSources.Concat(managedSources)); - var settings = new Mock().Object; - var logger = new Mock().Object; - string testCaseFilter = "TestFilter"; + string testCaseFilter = "TestFilter"; - this.discovererEnumerator.LoadTests(extensionSourceMap, settings, testCaseFilter, logger); + this.discovererEnumerator.LoadTests(extensionSourceMap, this.runSettingsMock.Object, testCaseFilter, this.messageLoggerMock.Object); - Assert.IsTrue(ManagedDllTestDiscoverer.IsManagedDiscoverTestCalled); - CollectionAssert.AreEqual(managedSources, ManagedDllTestDiscoverer.Sources.ToList()); + Assert.IsTrue(ManagedDllTestDiscoverer.IsManagedDiscoverTestCalled); + CollectionAssert.AreEqual(managedSources, ManagedDllTestDiscoverer.Sources.ToList()); - Assert.IsTrue(NativeDllTestDiscoverer.IsNativeDiscoverTestCalled); - CollectionAssert.AreEqual(nativeSources, NativeDllTestDiscoverer.Sources.ToList()); + Assert.IsTrue(NativeDllTestDiscoverer.IsNativeDiscoverTestCalled); + CollectionAssert.AreEqual(nativeSources, NativeDllTestDiscoverer.Sources.ToList()); - Assert.IsFalse(JsonTestDiscoverer.IsDiscoverTestCalled); - } - finally - { - this.ResetDiscoverers(); - } + Assert.IsFalse(JsonTestDiscoverer.IsDiscoverTestCalled); } [TestMethod] public void LoadTestsShouldCallIntoADiscovererThatMatchesTheSources() { - try - { - TestPluginCacheTests.SetupMockExtensions( - new string[] { typeof(DiscovererEnumeratorTests).GetTypeInfo().Assembly.Location }, - () => { }); - - var sources = new List - { - typeof(DiscoveryResultCacheTests).GetTypeInfo().Assembly.Location, - typeof(DiscoveryResultCacheTests).GetTypeInfo().Assembly.Location - }; + TestPluginCacheTests.SetupMockExtensions( + new string[] { typeof(DiscovererEnumeratorTests).GetTypeInfo().Assembly.Location }, + () => { }); - var extensionSourceMap = new Dictionary>(); - extensionSourceMap.Add("_none_", sources); + var sources = new List + { + typeof(DiscoveryResultCacheTests).GetTypeInfo().Assembly.Location, + typeof(DiscoveryResultCacheTests).GetTypeInfo().Assembly.Location + }; - var settings = new Mock().Object; - var logger = new Mock().Object; - string testCaseFilter = "TestFilter"; + var extensionSourceMap = new Dictionary>(); + extensionSourceMap.Add("_none_", sources); + string testCaseFilter = "TestFilter"; - this.discovererEnumerator.LoadTests(extensionSourceMap, settings, testCaseFilter, logger); + this.discovererEnumerator.LoadTests(extensionSourceMap, this.runSettingsMock.Object, testCaseFilter, this.messageLoggerMock.Object); - Assert.IsTrue(ManagedDllTestDiscoverer.IsManagedDiscoverTestCalled); - Assert.IsFalse(JsonTestDiscoverer.IsDiscoverTestCalled); + Assert.IsTrue(ManagedDllTestDiscoverer.IsManagedDiscoverTestCalled); + Assert.IsFalse(JsonTestDiscoverer.IsDiscoverTestCalled); - // Also validate that the right set of arguments were passed on to the discoverer. - CollectionAssert.AreEqual(sources, ManagedDllTestDiscoverer.Sources.ToList()); - Assert.AreEqual(settings, ManagedDllTestDiscoverer.DiscoveryContext.RunSettings); - Assert.AreEqual(testCaseFilter, (ManagedDllTestDiscoverer.DiscoveryContext as DiscoveryContext).FilterExpressionWrapper.FilterString); - Assert.AreEqual(logger, ManagedDllTestDiscoverer.MessageLogger); - Assert.IsNotNull(ManagedDllTestDiscoverer.DiscoverySink); - } - finally - { - this.ResetDiscoverers(); - } + // Also validate that the right set of arguments were passed on to the discoverer. + CollectionAssert.AreEqual(sources, ManagedDllTestDiscoverer.Sources.ToList()); + Assert.AreEqual(this.runSettingsMock.Object, ManagedDllTestDiscoverer.DiscoveryContext.RunSettings); + Assert.AreEqual(testCaseFilter, (ManagedDllTestDiscoverer.DiscoveryContext as DiscoveryContext).FilterExpressionWrapper.FilterString); + Assert.AreEqual(this.messageLoggerMock.Object, ManagedDllTestDiscoverer.MessageLogger); + Assert.IsNotNull(ManagedDllTestDiscoverer.DiscoverySink); } [TestMethod] public void LoadTestsShouldCallIntoMultipleDiscoverersThatMatchesTheSources() { - try - { - TestPluginCacheTests.SetupMockExtensions( - new string[] { typeof(DiscovererEnumeratorTests).GetTypeInfo().Assembly.Location }, - () => { }); + TestPluginCacheTests.SetupMockExtensions( + new string[] { typeof(DiscovererEnumeratorTests).GetTypeInfo().Assembly.Location }, + () => { }); - var dllsources = new List - { - typeof(DiscoveryResultCacheTests).GetTypeInfo().Assembly.Location, - typeof(DiscoveryResultCacheTests).GetTypeInfo().Assembly.Location - }; - var jsonsources = new List - { - "test1.json", - "test2.json" - }; - var sources = new List(dllsources); - sources.AddRange(jsonsources); + var dllsources = new List + { + typeof(DiscoveryResultCacheTests).GetTypeInfo().Assembly.Location, + typeof(DiscoveryResultCacheTests).GetTypeInfo().Assembly.Location + }; + var jsonsources = new List + { + "test1.json", + "test2.json" + }; + var sources = new List(dllsources); + sources.AddRange(jsonsources); - var extensionSourceMap = new Dictionary>(); - extensionSourceMap.Add("_none_", sources); + var extensionSourceMap = new Dictionary>(); + extensionSourceMap.Add("_none_", sources); - var settings = new Mock().Object; - var logger = new Mock().Object; - string testCaseFilter = "TestFilter"; + var runSettings = this.runSettingsMock.Object; - this.discovererEnumerator.LoadTests(extensionSourceMap, settings, testCaseFilter, logger); + string testCaseFilter = "TestFilter"; - Assert.IsTrue(ManagedDllTestDiscoverer.IsManagedDiscoverTestCalled); - Assert.IsTrue(JsonTestDiscoverer.IsDiscoverTestCalled); + this.discovererEnumerator.LoadTests(extensionSourceMap, runSettings, testCaseFilter, this.messageLoggerMock.Object); - // Also validate that the right set of arguments were passed on to the discoverer. - CollectionAssert.AreEqual(dllsources, ManagedDllTestDiscoverer.Sources.ToList()); - Assert.AreEqual(settings, ManagedDllTestDiscoverer.DiscoveryContext.RunSettings); - Assert.AreEqual(testCaseFilter, (ManagedDllTestDiscoverer.DiscoveryContext as DiscoveryContext).FilterExpressionWrapper.FilterString); - Assert.AreEqual(logger, ManagedDllTestDiscoverer.MessageLogger); - Assert.IsNotNull(ManagedDllTestDiscoverer.DiscoverySink); + Assert.IsTrue(ManagedDllTestDiscoverer.IsManagedDiscoverTestCalled); + Assert.IsTrue(JsonTestDiscoverer.IsDiscoverTestCalled); - CollectionAssert.AreEqual(jsonsources, JsonTestDiscoverer.Sources.ToList()); - Assert.AreEqual(settings, JsonTestDiscoverer.DiscoveryContext.RunSettings); - Assert.AreEqual(testCaseFilter, (JsonTestDiscoverer.DiscoveryContext as DiscoveryContext).FilterExpressionWrapper.FilterString); - Assert.AreEqual(logger, JsonTestDiscoverer.MessageLogger); - Assert.IsNotNull(JsonTestDiscoverer.DiscoverySink); - } - finally - { - this.ResetDiscoverers(); - } + // Also validate that the right set of arguments were passed on to the discoverer. + CollectionAssert.AreEqual(dllsources, ManagedDllTestDiscoverer.Sources.ToList()); + Assert.AreEqual(runSettings, ManagedDllTestDiscoverer.DiscoveryContext.RunSettings); + Assert.AreEqual(testCaseFilter, (ManagedDllTestDiscoverer.DiscoveryContext as DiscoveryContext).FilterExpressionWrapper.FilterString); + Assert.AreEqual(this.messageLoggerMock.Object, ManagedDllTestDiscoverer.MessageLogger); + Assert.IsNotNull(ManagedDllTestDiscoverer.DiscoverySink); + + CollectionAssert.AreEqual(jsonsources, JsonTestDiscoverer.Sources.ToList()); + Assert.AreEqual(runSettings, JsonTestDiscoverer.DiscoveryContext.RunSettings); + Assert.AreEqual(testCaseFilter, (JsonTestDiscoverer.DiscoveryContext as DiscoveryContext).FilterExpressionWrapper.FilterString); + Assert.AreEqual(this.messageLoggerMock.Object, JsonTestDiscoverer.MessageLogger); + Assert.IsNotNull(JsonTestDiscoverer.DiscoverySink); } [TestMethod] public void LoadTestsShouldCallIntoOtherDiscoverersWhenCreatingOneFails() { - try - { - TestPluginCacheTests.SetupMockExtensions( - new string[] { typeof(DiscovererEnumeratorTests).GetTypeInfo().Assembly.Location }, - () => { }); + TestPluginCacheTests.SetupMockExtensions( + new string[] { typeof(DiscovererEnumeratorTests).GetTypeInfo().Assembly.Location }, + () => { }); - var sources = new List - { - "test1.csv", - typeof(DiscoveryResultCacheTests).GetTypeInfo().Assembly.Location - }; + var sources = new List + { + "test1.csv", + typeof(DiscoveryResultCacheTests).GetTypeInfo().Assembly.Location + }; - var extensionSourceMap = new Dictionary>(); - extensionSourceMap.Add("_none_", sources); + var extensionSourceMap = new Dictionary>(); + extensionSourceMap.Add("_none_", sources); - var settings = new Mock().Object; - var logger = new Mock().Object; - string testCaseFilter = "TestFilter"; + var runSettings = this.runSettingsMock.Object; - this.discovererEnumerator.LoadTests(extensionSourceMap, settings, testCaseFilter, logger); + string testCaseFilter = "TestFilter"; - Assert.IsTrue(ManagedDllTestDiscoverer.IsManagedDiscoverTestCalled); - Assert.IsFalse(SingletonTestDiscoverer.IsDiscoverTestCalled); + this.discovererEnumerator.LoadTests(extensionSourceMap, runSettings, testCaseFilter, this.messageLoggerMock.Object); - // Also validate that the right set of arguments were passed on to the discoverer. - CollectionAssert.AreEqual(new List { sources[1] }, ManagedDllTestDiscoverer.Sources.ToList()); - Assert.AreEqual(settings, ManagedDllTestDiscoverer.DiscoveryContext.RunSettings); - Assert.AreEqual(testCaseFilter, (ManagedDllTestDiscoverer.DiscoveryContext as DiscoveryContext).FilterExpressionWrapper.FilterString); - Assert.AreEqual(logger, ManagedDllTestDiscoverer.MessageLogger); - Assert.IsNotNull(ManagedDllTestDiscoverer.DiscoverySink); - } - finally - { - this.ResetDiscoverers(); - } + Assert.IsTrue(ManagedDllTestDiscoverer.IsManagedDiscoverTestCalled); + Assert.IsFalse(SingletonTestDiscoverer.IsDiscoverTestCalled); + + // Also validate that the right set of arguments were passed on to the discoverer. + CollectionAssert.AreEqual(new List { sources[1] }, ManagedDllTestDiscoverer.Sources.ToList()); + Assert.AreEqual(runSettings, ManagedDllTestDiscoverer.DiscoveryContext.RunSettings); + Assert.AreEqual(testCaseFilter, (ManagedDllTestDiscoverer.DiscoveryContext as DiscoveryContext).FilterExpressionWrapper.FilterString); + Assert.AreEqual(this.messageLoggerMock.Object, ManagedDllTestDiscoverer.MessageLogger); + Assert.IsNotNull(ManagedDllTestDiscoverer.DiscoverySink); } [TestMethod] public void LoadTestsShouldCallIntoOtherDiscoverersEvenIfDiscoveryInOneFails() { - try - { - TestPluginCacheTests.SetupMockExtensions( - new string[] { typeof(DiscovererEnumeratorTests).GetTypeInfo().Assembly.Location }, - () => { }); + TestPluginCacheTests.SetupMockExtensions( + new string[] { typeof(DiscovererEnumeratorTests).GetTypeInfo().Assembly.Location }, + () => { }); - var sources = new List - { - "test1.cs", - typeof(DiscoveryResultCacheTests).GetTypeInfo().Assembly.Location - }; + var sources = new List + { + "test1.cs", + typeof(DiscoveryResultCacheTests).GetTypeInfo().Assembly.Location + }; - var extensionSourceMap = new Dictionary>(); - extensionSourceMap.Add("_none_", sources); + var extensionSourceMap = new Dictionary>(); + extensionSourceMap.Add("_none_", sources); - var settings = new Mock().Object; - var mocklogger = new Mock(); - string testCaseFilter = "TestFilter"; + var runSettings = this.runSettingsMock.Object; - this.discovererEnumerator.LoadTests(extensionSourceMap, settings, testCaseFilter, mocklogger.Object); + string testCaseFilter = "TestFilter"; - Assert.IsTrue(ManagedDllTestDiscoverer.IsManagedDiscoverTestCalled); - Assert.IsTrue(NotImplementedTestDiscoverer.IsDiscoverTestCalled); + this.discovererEnumerator.LoadTests(extensionSourceMap, runSettings, testCaseFilter, this.messageLoggerMock.Object); - // Also validate that the right set of arguments were passed on to the discoverer. - CollectionAssert.AreEqual(new List { sources[1] }, ManagedDllTestDiscoverer.Sources.ToList()); - Assert.AreEqual(settings, ManagedDllTestDiscoverer.DiscoveryContext.RunSettings); - Assert.AreEqual(testCaseFilter, (ManagedDllTestDiscoverer.DiscoveryContext as DiscoveryContext).FilterExpressionWrapper.FilterString); - Assert.AreEqual(mocklogger.Object, ManagedDllTestDiscoverer.MessageLogger); - Assert.IsNotNull(ManagedDllTestDiscoverer.DiscoverySink); + Assert.IsTrue(ManagedDllTestDiscoverer.IsManagedDiscoverTestCalled); + Assert.IsTrue(NotImplementedTestDiscoverer.IsDiscoverTestCalled); - // Check if we log the failure. - var message = string.Format( - CultureInfo.CurrentUICulture, - "An exception occurred while test discoverer '{0}' was loading tests. Exception: {1}", - typeof(NotImplementedTestDiscoverer).Name, - "The method or operation is not implemented."); + // Also validate that the right set of arguments were passed on to the discoverer. + CollectionAssert.AreEqual(new List { sources[1] }, ManagedDllTestDiscoverer.Sources.ToList()); + Assert.AreEqual(runSettings, ManagedDllTestDiscoverer.DiscoveryContext.RunSettings); + Assert.AreEqual(testCaseFilter, (ManagedDllTestDiscoverer.DiscoveryContext as DiscoveryContext).FilterExpressionWrapper.FilterString); + Assert.AreEqual(this.messageLoggerMock.Object, ManagedDllTestDiscoverer.MessageLogger); + Assert.IsNotNull(ManagedDllTestDiscoverer.DiscoverySink); - mocklogger.Verify(l => l.SendMessage(TestMessageLevel.Error, message), Times.Once); - } - finally - { - this.ResetDiscoverers(); - } + // Check if we log the failure. + var message = string.Format( + CultureInfo.CurrentUICulture, + "An exception occurred while test discoverer '{0}' was loading tests. Exception: {1}", + typeof(NotImplementedTestDiscoverer).Name, + "The method or operation is not implemented."); + + this.messageLoggerMock.Verify(l => l.SendMessage(TestMessageLevel.Error, message), Times.Once); } [TestMethod] public void LoadTestsShouldCollectMetrics() { - try - { - var mockMetricsCollector = new Mock(); - var dict = new Dictionary(); - dict.Add("DummyMessage", "DummyValue"); + var mockMetricsCollector = new Mock(); + var dict = new Dictionary(); + dict.Add("DummyMessage", "DummyValue"); - TestPluginCacheTests.SetupMockExtensions( - new string[] { typeof(DiscovererEnumeratorTests).GetTypeInfo().Assembly.Location }, - () => { }); - - var sources = new List - { - typeof(DiscoveryResultCacheTests).GetTypeInfo().Assembly.Location, - typeof(DiscoveryResultCacheTests).GetTypeInfo().Assembly.Location - }; + TestPluginCacheTests.SetupMockExtensions( + new string[] { typeof(DiscovererEnumeratorTests).GetTypeInfo().Assembly.Location }, + () => { }); - var extensionSourceMap = new Dictionary>(); - extensionSourceMap.Add("_none_", sources); + var sources = new List + { + typeof(DiscoveryResultCacheTests).GetTypeInfo().Assembly.Location, + typeof(DiscoveryResultCacheTests).GetTypeInfo().Assembly.Location + }; - var settings = new Mock().Object; - var logger = new Mock().Object; + var extensionSourceMap = new Dictionary>(); + extensionSourceMap.Add("_none_", sources); - mockMetricsCollector.Setup(mc => mc.Metrics).Returns(dict); - this.mockRequestData.Setup(rd => rd.MetricsCollection).Returns(mockMetricsCollector.Object); + mockMetricsCollector.Setup(mc => mc.Metrics).Returns(dict); + this.mockRequestData.Setup(rd => rd.MetricsCollection).Returns(mockMetricsCollector.Object); + + string testCaseFilter = "TestFilter"; + this.discovererEnumerator.LoadTests(extensionSourceMap, this.runSettingsMock.Object, testCaseFilter, this.messageLoggerMock.Object); + + // Verify. + mockMetricsCollector.Verify(rd => rd.Add(TelemetryDataConstants.TimeTakenInSecByAllAdapters, It.IsAny()), Times.Once); + mockMetricsCollector.Verify(rd => rd.Add(TelemetryDataConstants.NumberOfAdapterUsedToDiscoverTests, It.IsAny()), Times.Once); + mockMetricsCollector.Verify(rd => rd.Add(TelemetryDataConstants.NumberOfAdapterDiscoveredDuringDiscovery, It.IsAny()), Times.Once); + mockMetricsCollector.Verify(rd => rd.Add(TelemetryDataConstants.TotalTestsByAdapter + ".discoverer://manageddlldiscoverer/", It.IsAny()), Times.Once); + mockMetricsCollector.Verify(rd => rd.Add(TelemetryDataConstants.TimeTakenToDiscoverTestsByAnAdapter + ".discoverer://manageddlldiscoverer/", It.IsAny()), Times.Once); + mockMetricsCollector.Verify(rd => rd.Add(TelemetryDataConstants.TotalTestsByAdapter + ".discoverer://nativedlldiscoverer/", It.IsAny()), Times.Once); + mockMetricsCollector.Verify(rd => rd.Add(TelemetryDataConstants.TimeTakenToDiscoverTestsByAnAdapter + ".discoverer://nativedlldiscoverer/", It.IsAny()), Times.Once); + mockMetricsCollector.Verify(rd => rd.Add(TelemetryDataConstants.TimeTakenToLoadAdaptersInSec, It.IsAny()), Times.Once); + } - string testCaseFilter = "TestFilter"; - this.discovererEnumerator.LoadTests(extensionSourceMap, settings, testCaseFilter, logger); + [TestMethod] + public void LoadTestsShouldCallIntoTheAdapterWithTheRightTestCaseSink() + { + this.InvokeLoadTestWithMockSetup(); - // Verify. - mockMetricsCollector.Verify(rd => rd.Add(TelemetryDataConstants.TimeTakenInSecByAllAdapters, It.IsAny()), Times.Once); - mockMetricsCollector.Verify(rd => rd.Add(TelemetryDataConstants.NumberOfAdapterUsedToDiscoverTests, It.IsAny()), Times.Once); - mockMetricsCollector.Verify(rd => rd.Add(TelemetryDataConstants.NumberOfAdapterDiscoveredDuringDiscovery, It.IsAny()), Times.Once); - mockMetricsCollector.Verify(rd => rd.Add(TelemetryDataConstants.TotalTestsByAdapter + ".discoverer://manageddlldiscoverer/", It.IsAny()), Times.Once); - mockMetricsCollector.Verify(rd => rd.Add(TelemetryDataConstants.TimeTakenToDiscoverTestsByAnAdapter + ".discoverer://manageddlldiscoverer/", It.IsAny()), Times.Once); - mockMetricsCollector.Verify(rd => rd.Add(TelemetryDataConstants.TotalTestsByAdapter + ".discoverer://nativedlldiscoverer/", It.IsAny()), Times.Once); - mockMetricsCollector.Verify(rd => rd.Add(TelemetryDataConstants.TimeTakenToDiscoverTestsByAnAdapter + ".discoverer://nativedlldiscoverer/", It.IsAny()), Times.Once); - mockMetricsCollector.Verify(rd => rd.Add(TelemetryDataConstants.TimeTakenToLoadAdaptersInSec, It.IsAny()), Times.Once); - } - finally - { - this.ResetDiscoverers(); - } + Assert.IsTrue(ManagedDllTestDiscoverer.IsManagedDiscoverTestCalled); + Assert.AreEqual(2, this.discoveryResultCache.Tests.Count); } [TestMethod] - public void LoadTestsShouldCallIntoTheAdapterWithTheRightTestCaseSink() + public void LoadTestsShouldNotShowAnyWarningOnTestsDiscovered() { - try - { - this.InvokeLoadTestWithMockSetup(); + this.InvokeLoadTestWithMockSetup(); - Assert.IsTrue(ManagedDllTestDiscoverer.IsManagedDiscoverTestCalled); - Assert.AreEqual(2, this.discoveryResultCache.Tests.Count); - } - finally - { - this.ResetDiscoverers(); - } + Assert.AreEqual(2, this.discoveryResultCache.Tests.Count); + + this.messageLoggerMock.Verify(m => m.SendMessage(TestMessageLevel.Warning, It.IsAny()), Times.Never); } [TestMethod] public void LoadTestShouldInstrumentDiscoveryStart() { - try - { - this.InvokeLoadTestWithMockSetup(); - this.mockTestPlatformEventSource.Verify(x => x.DiscoveryStart(), Times.Once); - } - finally - { - this.ResetDiscoverers(); - } + this.InvokeLoadTestWithMockSetup(); + this.mockTestPlatformEventSource.Verify(x => x.DiscoveryStart(), Times.Once); } [TestMethod] public void LoadTestShouldInstrumentDiscoveryStop() { - try - { - this.InvokeLoadTestWithMockSetup(); - this.mockTestPlatformEventSource.Verify(x => x.DiscoveryStop(It.IsAny()), Times.Once); - } - finally - { - this.ResetDiscoverers(); - } + this.InvokeLoadTestWithMockSetup(); + this.mockTestPlatformEventSource.Verify(x => x.DiscoveryStop(It.IsAny()), Times.Once); } [TestMethod] public void LoadTestShouldInstrumentAdapterDiscoveryStart() { - try - { - this.InvokeLoadTestWithMockSetup(); - this.mockTestPlatformEventSource.Verify(x => x.AdapterDiscoveryStart(It.IsAny()), Times.AtLeastOnce); - } - finally - { - this.ResetDiscoverers(); - } + this.InvokeLoadTestWithMockSetup(); + this.mockTestPlatformEventSource.Verify(x => x.AdapterDiscoveryStart(It.IsAny()), Times.AtLeastOnce); } [TestMethod] public void LoadTestShouldInstrumentAdapterDiscoveryStop() { - try - { - this.InvokeLoadTestWithMockSetup(); - this.mockTestPlatformEventSource.Verify(x => x.AdapterDiscoveryStop(It.IsAny()), Times.AtLeastOnce); - } - finally - { - this.ResetDiscoverers(); - } + this.InvokeLoadTestWithMockSetup(); + this.mockTestPlatformEventSource.Verify(x => x.AdapterDiscoveryStop(It.IsAny()), Times.AtLeastOnce); } [TestMethod] public void LoadTestsShouldIterateOverAllExtensionsInTheMapAndDiscoverTests() { - try - { - TestPluginCacheTests.SetupMockExtensions( - new string[] { typeof(DiscovererEnumeratorTests).GetTypeInfo().Assembly.Location }, - () => { }); + TestPluginCacheTests.SetupMockExtensions( + new string[] { typeof(DiscovererEnumeratorTests).GetTypeInfo().Assembly.Location }, + () => { }); - var dllsources = new List - { - typeof(DiscoveryResultCacheTests).GetTypeInfo().Assembly.Location, - typeof(DiscoveryResultCacheTests).GetTypeInfo().Assembly.Location - }; - var jsonsources = new List - { - "test1.json", - "test2.json" - }; + var dllsources = new List + { + typeof(DiscoveryResultCacheTests).GetTypeInfo().Assembly.Location, + typeof(DiscoveryResultCacheTests).GetTypeInfo().Assembly.Location + }; + var jsonsources = new List + { + "test1.json", + "test2.json" + }; - var extensionSourceMap = new Dictionary>(); - extensionSourceMap.Add(typeof(DiscovererEnumeratorTests).GetTypeInfo().Assembly.Location, jsonsources); - extensionSourceMap.Add("_none_", dllsources); + var extensionSourceMap = new Dictionary>(); + extensionSourceMap.Add(typeof(DiscovererEnumeratorTests).GetTypeInfo().Assembly.Location, jsonsources); + extensionSourceMap.Add("_none_", dllsources); - var settings = new Mock().Object; - var logger = new Mock().Object; - string testCaseFilter = "TestFilter"; + var runSettings = this.runSettingsMock.Object; - this.discovererEnumerator.LoadTests(extensionSourceMap, settings, testCaseFilter, logger); + string testCaseFilter = "TestFilter"; - Assert.IsTrue(ManagedDllTestDiscoverer.IsManagedDiscoverTestCalled); - Assert.IsTrue(JsonTestDiscoverer.IsDiscoverTestCalled); + this.discovererEnumerator.LoadTests(extensionSourceMap, runSettings, testCaseFilter, this.messageLoggerMock.Object); - // Also validate that the right set of arguments were passed on to the discoverer. - CollectionAssert.AreEqual(dllsources, ManagedDllTestDiscoverer.Sources.ToList()); - Assert.AreEqual(settings, ManagedDllTestDiscoverer.DiscoveryContext.RunSettings); - Assert.AreEqual(testCaseFilter, (ManagedDllTestDiscoverer.DiscoveryContext as DiscoveryContext).FilterExpressionWrapper.FilterString); - Assert.AreEqual(logger, ManagedDllTestDiscoverer.MessageLogger); - Assert.IsNotNull(ManagedDllTestDiscoverer.DiscoverySink); + Assert.IsTrue(ManagedDllTestDiscoverer.IsManagedDiscoverTestCalled); + Assert.IsTrue(JsonTestDiscoverer.IsDiscoverTestCalled); - CollectionAssert.AreEqual(jsonsources, JsonTestDiscoverer.Sources.ToList()); - Assert.AreEqual(settings, JsonTestDiscoverer.DiscoveryContext.RunSettings); - Assert.AreEqual(testCaseFilter, (JsonTestDiscoverer.DiscoveryContext as DiscoveryContext).FilterExpressionWrapper.FilterString); - Assert.AreEqual(logger, JsonTestDiscoverer.MessageLogger); - Assert.IsNotNull(JsonTestDiscoverer.DiscoverySink); - } - finally - { - this.ResetDiscoverers(); - } + // Also validate that the right set of arguments were passed on to the discoverer. + CollectionAssert.AreEqual(dllsources, ManagedDllTestDiscoverer.Sources.ToList()); + Assert.AreEqual(runSettings, ManagedDllTestDiscoverer.DiscoveryContext.RunSettings); + Assert.AreEqual(testCaseFilter, (ManagedDllTestDiscoverer.DiscoveryContext as DiscoveryContext).FilterExpressionWrapper.FilterString); + Assert.AreEqual(this.messageLoggerMock.Object, ManagedDllTestDiscoverer.MessageLogger); + Assert.IsNotNull(ManagedDllTestDiscoverer.DiscoverySink); + + CollectionAssert.AreEqual(jsonsources, JsonTestDiscoverer.Sources.ToList()); + Assert.AreEqual(runSettings, JsonTestDiscoverer.DiscoveryContext.RunSettings); + Assert.AreEqual(testCaseFilter, (JsonTestDiscoverer.DiscoveryContext as DiscoveryContext).FilterExpressionWrapper.FilterString); + Assert.AreEqual(this.messageLoggerMock.Object, JsonTestDiscoverer.MessageLogger); + Assert.IsNotNull(JsonTestDiscoverer.DiscoverySink); } - private void ResetDiscoverers() + [TestMethod] + public void LoadTestsShouldLogWarningMessageOnNoTestsInAssemblies() { - ManagedDllTestDiscoverer.Reset(); - NativeDllTestDiscoverer.Reset(); - JsonTestDiscoverer.Reset(); - NotImplementedTestDiscoverer.Reset(); + DiscovererEnumeratorTests.SetupForNoTestsAvailableInGivenAssemblies(out var extensionSourceMap, out var sourcesString); + + this.discovererEnumerator.LoadTests(extensionSourceMap, this.runSettingsMock.Object, null, this.messageLoggerMock.Object); + + var expectedMessage = + $"No test is available in {sourcesString}. Make sure that test discoverer & executors are registered and platform & framework version settings are appropriate and try again."; + + this.messageLoggerMock.Verify( l => l.SendMessage(TestMessageLevel.Warning, expectedMessage)); + } + + [TestMethod] + public void LoadTestsShouldLogWarningMessageOnNoTestsInAssembliesWithTestCaseFilter() + { + DiscovererEnumeratorTests.SetupForNoTestsAvailableInGivenAssemblies(out var extensionSourceMap, out var sourcesString); + + var testCaseFilter = "Name~TestMethod1"; + + this.discovererEnumerator.LoadTests(extensionSourceMap, this.runSettingsMock.Object, testCaseFilter, this.messageLoggerMock.Object); + + var expectedMessage = + $"No test is available for testcase filter `{testCaseFilter}` in {sourcesString}"; + + this.messageLoggerMock.Verify(l => l.SendMessage(TestMessageLevel.Warning, expectedMessage)); + } + + [TestMethod] + public void LoadTestsShouldShortenTheLongTestCaseFilterWhenNoTestsDiscovered() + { + DiscovererEnumeratorTests.SetupForNoTestsAvailableInGivenAssemblies(out var extensionSourceMap, out var sourcesString); + + var veryLengthyTestCaseFilter = "FullyQualifiedName=TestPlatform.CrossPlatEngine" + + ".UnitTests.Discovery.DiscovererEnumeratorTests." + + "LoadTestsShouldShortenTheLongTestCaseFilterWhenNoTestsDiscovered" + + "TestCaseFilterWithVeryLengthTestCaseNameeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"; + + this.discovererEnumerator.LoadTests(extensionSourceMap, this.runSettingsMock.Object, veryLengthyTestCaseFilter, this.messageLoggerMock.Object); + + var expectedTestCaseFilter = veryLengthyTestCaseFilter.Substring(0, 256) + "..."; + var expectedMessage = + $"No test is available for testcase filter `{expectedTestCaseFilter}` in {sourcesString}"; + + this.messageLoggerMock.Verify(l => l.SendMessage(TestMessageLevel.Warning, expectedMessage)); + } + + private static void SetupForNoTestsAvailableInGivenAssemblies( + out Dictionary> extensionSourceMap, + out string sourcesString) + { + var crossPlatEngineAssemblyLocation = typeof(DiscovererEnumerator).GetTypeInfo().Assembly.Location; + var objectModelAseeAssemblyLocation = typeof(TestCase).GetTypeInfo().Assembly.Location; + var sources = new string[] { crossPlatEngineAssemblyLocation, objectModelAseeAssemblyLocation }; + + extensionSourceMap = new Dictionary>(); + extensionSourceMap.Add("_none_", sources); + sourcesString = string.Join(" ", crossPlatEngineAssemblyLocation, objectModelAseeAssemblyLocation); } private void InvokeLoadTestWithMockSetup() @@ -585,13 +547,9 @@ private void InvokeLoadTestWithMockSetup() var extensionSourceMap = new Dictionary>(); extensionSourceMap.Add("_none_", sources); - var settings = new Mock().Object; - var logger = new Mock().Object; - - this.discovererEnumerator.LoadTests(extensionSourceMap, settings, null, logger); + this.discovererEnumerator.LoadTests(extensionSourceMap, this.runSettingsMock.Object, null, this.messageLoggerMock.Object); } - #region implementation /// @@ -645,7 +603,6 @@ private class ManagedDllTestDiscoverer : DllTestDiscoverer public static IEnumerable Sources { get; set; } - public override void DiscoverTests(IEnumerable sources, IDiscoveryContext discoveryContext, IMessageLogger logger, ITestCaseDiscoverySink discoverySink) { Sources = sources; @@ -693,6 +650,11 @@ private class DllTestDiscoverer : ITestDiscoverer public virtual void DiscoverTests(IEnumerable sources, IDiscoveryContext discoveryContext, IMessageLogger logger, ITestCaseDiscoverySink discoverySink) { + if (DllTestDiscoverer.ShouldTestDiscovered(sources) == false) + { + return; + } + DiscoveryContext = discoveryContext; MessageLogger = logger; DiscoverySink = discoverySink; @@ -700,6 +662,21 @@ public virtual void DiscoverTests(IEnumerable sources, IDiscoveryContext var testCase = new TestCase("A.C.M", new Uri("executor://dllexecutor"), "A"); discoverySink.SendTestCase(testCase); } + + private static bool ShouldTestDiscovered(IEnumerable sources) + { + var shouldTestDiscovered = false; + foreach (var source in sources) + { + if (source.Equals("native.dll") || source.Equals("managed.dll") || source.EndsWith("CrossPlatEngine.UnitTests.dll")) + { + shouldTestDiscovered = true; + break; + } + } + + return shouldTestDiscovered; + } } [FileExtension(".json")] diff --git a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Execution/RunTestsWithSourcesTests.cs b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Execution/RunTestsWithSourcesTests.cs index 3f4816f4db..0e00b3eb84 100644 --- a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Execution/RunTestsWithSourcesTests.cs +++ b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Execution/RunTestsWithSourcesTests.cs @@ -93,7 +93,7 @@ public void BeforeRaisingTestRunCompleteShouldWarnIfNoTestsAreRun() this.mockTestRunEventsHandler.Object, executorUriVsSourceList, this.mockRequestData.Object); - + this.runTestsInstance.CallBeforeRaisingTestRunComplete(false); var messageFormat = @@ -198,7 +198,7 @@ public void RunTestsShouldRunTestsForTheSourcesSpecified() bool isExecutorCalled = false; RunTestWithSourcesExecutor.RunTestsWithSourcesCallback = (s, rc, fh) => { isExecutorCalled = true; }; - + this.runTestsInstance.RunTests(); Assert.IsTrue(isExecutorCalled); @@ -209,6 +209,74 @@ public void RunTestsShouldRunTestsForTheSourcesSpecified() It.IsAny>()), Times.Once); } + [TestMethod] + public void RunTestsShouldLogWarningOnNoTestsAvailableInAssembly() + { + string testCaseFilter = null; + this.SetupForNoTestsAvailable(testCaseFilter, out var sourcesString); + + this.runTestsInstance.RunTests(); + + var expectedMessage = + $"No test is available in {sourcesString}. Make sure that test discoverer & executors are registered and platform & framework version settings are appropriate and try again."; + this.mockTestRunEventsHandler.Verify(treh => treh.HandleLogMessage(TestMessageLevel.Warning, expectedMessage), Times.Once); + } + + [TestMethod] + public void RunTestsShouldLogWarningOnNoTestsAvailableInAssemblyWithTestCaseFilter() + { + var testCaseFilter = "Name~TestMethod1"; + this.SetupForNoTestsAvailable(testCaseFilter, out var sourcesString); + + this.runTestsInstance.RunTests(); + + var expectedMessage = + $"No test is available for testcase filter `{testCaseFilter}` in {sourcesString}"; + this.mockTestRunEventsHandler.Verify(treh => treh.HandleLogMessage(TestMessageLevel.Warning, expectedMessage), Times.Once); + } + + [TestMethod] + public void RunTestsShouldLogWarningOnNoTestsAvailableInAssemblyWithLongTestCaseFilter() + { + var veryLengthyTestCaseFilter = "FullyQualifiedName=TestPlatform.CrossPlatEngine" + + ".UnitTests.Execution.RunTestsWithSourcesTests." + + "RunTestsShouldLogWarningOnNoTestsAvailableInAssemblyWithLongTestCaseFilter" + + "WithVeryLengthTestCaseNameeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"; + this.SetupForNoTestsAvailable(veryLengthyTestCaseFilter, out var sourcesString); + + this.runTestsInstance.RunTests(); + + var expectedTestCaseFilter = veryLengthyTestCaseFilter.Substring(0, 256)+ "..."; + + var expectedMessage = + $"No test is available for testcase filter `{expectedTestCaseFilter}` in {sourcesString}"; + this.mockTestRunEventsHandler.Verify(treh => treh.HandleLogMessage(TestMessageLevel.Warning, expectedMessage), Times.Once); + } + + private void SetupForNoTestsAvailable(string testCaseFilter, out string sourcesString) + { + var testAssemblyLocation = typeof(TestCase).GetTypeInfo().Assembly.Location; + + var adapterAssemblyLocation = typeof(RunTestsWithSourcesTests).GetTypeInfo().Assembly.Location; + + var adapterSourceMap = new Dictionary>(); + + var sources = new[] {testAssemblyLocation, "a"}; + sourcesString = string.Join(" ", sources); + + adapterSourceMap.Add(adapterAssemblyLocation, sources); + + this.testExecutionContext.TestCaseFilter = testCaseFilter; + + this.runTestsInstance = new TestableRunTestsWithSources( + adapterSourceMap, + null, + testExecutionContext, + null, + this.mockTestRunEventsHandler.Object, + this.mockRequestData.Object); + } + #region Testable Implemetations private class TestableRunTestsWithSources : RunTestsWithSources diff --git a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Microsoft.TestPlatform.CrossPlatEngine.UnitTests.csproj b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Microsoft.TestPlatform.CrossPlatEngine.UnitTests.csproj index 5b2fe5179b..3bd634be4c 100644 --- a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Microsoft.TestPlatform.CrossPlatEngine.UnitTests.csproj +++ b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Microsoft.TestPlatform.CrossPlatEngine.UnitTests.csproj @@ -9,6 +9,8 @@ Exe Microsoft.TestPlatform.CrossPlatEngine.UnitTests netcoreapp1.0;net451 + diff --git a/test/Microsoft.TestPlatform.TestUtilities/IntegrationTestBase.cs b/test/Microsoft.TestPlatform.TestUtilities/IntegrationTestBase.cs index b200e400bb..c38d8026a8 100644 --- a/test/Microsoft.TestPlatform.TestUtilities/IntegrationTestBase.cs +++ b/test/Microsoft.TestPlatform.TestUtilities/IntegrationTestBase.cs @@ -50,6 +50,10 @@ public IntegrationTestBase() this.testEnvironment = new IntegrationTestEnvironment(); } + public string StdOut => this.standardTestOutput; + + public string StdErr => this.standardTestError; + /// /// Prepare arguments for vstest.console.exe. /// @@ -403,7 +407,19 @@ protected virtual string SetVSTestConsoleDLLPathInArgs(string args) /// public IVsTestConsoleWrapper GetVsTestConsoleWrapper() { - var vstestConsoleWrapper = new VsTestConsoleWrapper(this.GetConsoleRunnerPath()); + var logFileName = Path.GetFileName(Path.GetTempFileName()); + var logFileDir = Path.Combine(Path.GetTempPath(), "VSTestConsoleWrapperLogs"); + + if (Directory.Exists(logFileDir) == false) + { + Directory.CreateDirectory(logFileDir); + } + + var logFilePath = Path.Combine(logFileDir, logFileName); + + Console.WriteLine($"Logging diagnostics in {logFilePath}"); + + var vstestConsoleWrapper = new VsTestConsoleWrapper(this.GetConsoleRunnerPath(), new ConsoleParameters(){LogFilePath = logFilePath}); vstestConsoleWrapper.StartSession(); return vstestConsoleWrapper; diff --git a/test/vstest.console.UnitTests/Internal/ConsoleLoggerTests.cs b/test/vstest.console.UnitTests/Internal/ConsoleLoggerTests.cs index 7cddd38768..2fe8ac1ab0 100644 --- a/test/vstest.console.UnitTests/Internal/ConsoleLoggerTests.cs +++ b/test/vstest.console.UnitTests/Internal/ConsoleLoggerTests.cs @@ -133,17 +133,13 @@ public void TestMessageHandlerShouldThrowExceptionIfEventArgsIsNull() } [TestMethod] - public void TestMessageHandlerShouldWriteToConsoleIfTestRunEventsAreRaised() + public void TestMessageHandlerShouldWriteToConsoleWhenTestRunMessageIsRaised() { var count = 0; this.mockOutput.Setup(o => o.WriteLine(It.IsAny(), It.IsAny())).Callback( (s, o) => { count++; }); - var loggerEvents = new InternalTestLoggerEvents(TestSessionMessageLogger.Instance); - loggerEvents.EnableEvents(); - var parameters = new Dictionary(); - parameters.Add("verbosity", "normal"); - this.consoleLogger.Initialize(loggerEvents, parameters); + this.SetupForTestMessageHandler(out var loggerEvents); loggerEvents.RaiseTestRunMessage(new TestRunMessageEventArgs(TestMessageLevel.Informational, "Informational123")); loggerEvents.RaiseTestRunMessage(new TestRunMessageEventArgs(TestMessageLevel.Error, "Error123")); @@ -152,11 +148,44 @@ public void TestMessageHandlerShouldWriteToConsoleIfTestRunEventsAreRaised() // Added this for synchronization SpinWait.SpinUntil(() => count == 3, 300); + this.AssertsForTestMessageHandler(); + } + + [TestMethod] + public void TestMessageHandlerShouldWriteToConsoleWhenTestDiscoveryMessageIsRaised() + { + var count = 0; + this.mockOutput.Setup(o => o.WriteLine(It.IsAny(), It.IsAny())).Callback( + (s, o) => { count++; }); + + this.SetupForTestMessageHandler(out var loggerEvents); + + loggerEvents.RaiseDiscoveryMessage(new TestRunMessageEventArgs(TestMessageLevel.Informational, "Informational123")); + loggerEvents.RaiseDiscoveryMessage(new TestRunMessageEventArgs(TestMessageLevel.Error, "Error123")); + loggerEvents.RaiseDiscoveryMessage(new TestRunMessageEventArgs(TestMessageLevel.Warning, "Warning123")); + + // Added this for synchronization + SpinWait.SpinUntil(() => count == 3, 300); + + this.AssertsForTestMessageHandler(); + } + + private void AssertsForTestMessageHandler() + { this.mockOutput.Verify(o => o.WriteLine("Informational123", OutputLevel.Information), Times.Once()); this.mockOutput.Verify(o => o.WriteLine("Warning123", OutputLevel.Warning), Times.Once()); this.mockOutput.Verify(o => o.WriteLine("Error123", OutputLevel.Error), Times.Once()); } + private void SetupForTestMessageHandler(out InternalTestLoggerEvents loggerEvents) + { + loggerEvents = new InternalTestLoggerEvents(TestSessionMessageLogger.Instance); + loggerEvents.EnableEvents(); + var parameters = new Dictionary(); + parameters.Add("verbosity", "normal"); + this.consoleLogger.Initialize(loggerEvents, parameters); + } + [TestMethod] public void TestResultHandlerShouldThowExceptionIfEventArgsIsNull() {