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}
+
+