Add information about which assembly failed to discover test into (#299)

* Add information about which assembly failed to discover test into
Having indicate location of the assembly from which discovery happens allow developer reason about possible failures, and manually troubleshoot his configuration issues which cause asembly to fail

* Fix comments to PR
* Single messages for assembly loading failure
* Display assembly name for WinRT assembly loading

* Add XLF resources

* Fix failed tests

* Adjust test with changes in the error message reporting
This commit is contained in:
Andrey Kurdyumov 2018-01-05 15:19:29 +06:00 коммит произвёл Jayarani garg
Родитель cebf038007
Коммит f6654607a2
18 изменённых файлов: 114 добавлений и 5 удалений

Просмотреть файл

@ -88,16 +88,31 @@ namespace Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.Discovery
}
catch (Exception e)
{
warnings.Add(e.Message);
var winrtFailureMessage = string.Format(
CultureInfo.CurrentCulture,
Resource.TestAssembly_AssemblyDiscoveryFailure,
assemblyFileName,
e.Message);
warnings.Add(winrtFailureMessage);
return null;
}
warnings.Add(ex.Message);
var message = string.Format(
CultureInfo.CurrentCulture,
Resource.TestAssembly_AssemblyDiscoveryFailure,
fullFilePath,
ex.Message);
warnings.Add(message);
return null;
}
catch (ReflectionTypeLoadException ex)
{
warnings.Add(ex.Message);
var message = string.Format(
CultureInfo.CurrentCulture,
Resource.TestAssembly_AssemblyDiscoveryFailure,
fullFilePath,
ex.Message);
warnings.Add(message);
PlatformServiceProvider.Instance.AdapterTraceLogger.LogWarning(
"MSPhoneTestDiscoverer.TryGetTests: Failed to discover tests from {0}. Reason:{1}",
assemblyFileName,
@ -129,7 +144,14 @@ namespace Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.Discovery
"MSTestDiscoverer.TryGetTests: Failed to discover tests from {0}. Reason:{1}",
assemblyFileName,
ex);
warnings.Add(ex.Message);
var message = ex is FileNotFoundException fileNotFoundEx
? fileNotFoundEx.Message
: string.Format(
CultureInfo.CurrentCulture,
Resource.TestAssembly_AssemblyDiscoveryFailure,
fullFilePath,
ex.Message);
warnings.Add(message);
return null;
}
}

Просмотреть файл

@ -205,6 +205,15 @@ namespace Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter {
}
}
/// <summary>
/// Looks up a localized string similar to Failed to discover tests from assembly {0}. Reason:{1}.
/// </summary>
internal static string TestAssembly_AssemblyDiscoveryFailure {
get {
return ResourceManager.GetString("TestAssembly_AssemblyDiscoveryFailure", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to File does not exist: {0}.
/// </summary>

Просмотреть файл

@ -310,4 +310,7 @@
<value>Invalid value '{0}' specified for 'Workers'. The value should be a non-negative integer.</value>
<comment>`Workers` is a setting name that shouldn't be localized.</comment>
</data>
<data name="TestAssembly_AssemblyDiscoveryFailure" xml:space="preserve">
<value>Failed to discover tests from assembly {0}. Reason:{1}</value>
</data>
</root>

Просмотреть файл

@ -321,6 +321,11 @@
<target state="new">Invalid value '{0}' specified for 'Workers'. The value should be a non-negative integer.</target>
<note>`Workers` is a setting name that shouldn't be localized.</note>
</trans-unit>
<trans-unit id="TestAssembly_AssemblyDiscoveryFailure">
<source>Failed to discover tests from assembly {0}. Reason:{1}</source>
<target state="new">Failed to discover tests from assembly {0}. Reason:{1}</target>
<note></note>
</trans-unit>
</body>
</file>
</xliff>

Просмотреть файл

@ -321,6 +321,11 @@
<target state="new">Invalid value '{0}' specified for 'Workers'. The value should be a non-negative integer.</target>
<note>`Workers` is a setting name that shouldn't be localized.</note>
</trans-unit>
<trans-unit id="TestAssembly_AssemblyDiscoveryFailure">
<source>Failed to discover tests from assembly {0}. Reason:{1}</source>
<target state="new">Failed to discover tests from assembly {0}. Reason:{1}</target>
<note></note>
</trans-unit>
</body>
</file>
</xliff>

Просмотреть файл

@ -321,6 +321,11 @@
<target state="new">Invalid value '{0}' specified for 'Workers'. The value should be a non-negative integer.</target>
<note>`Workers` is a setting name that shouldn't be localized.</note>
</trans-unit>
<trans-unit id="TestAssembly_AssemblyDiscoveryFailure">
<source>Failed to discover tests from assembly {0}. Reason:{1}</source>
<target state="new">Failed to discover tests from assembly {0}. Reason:{1}</target>
<note></note>
</trans-unit>
</body>
</file>
</xliff>

Просмотреть файл

@ -321,6 +321,11 @@
<target state="new">Invalid value '{0}' specified for 'Workers'. The value should be a non-negative integer.</target>
<note>`Workers` is a setting name that shouldn't be localized.</note>
</trans-unit>
<trans-unit id="TestAssembly_AssemblyDiscoveryFailure">
<source>Failed to discover tests from assembly {0}. Reason:{1}</source>
<target state="new">Failed to discover tests from assembly {0}. Reason:{1}</target>
<note></note>
</trans-unit>
</body>
</file>
</xliff>

Просмотреть файл

@ -321,6 +321,11 @@
<target state="new">Invalid value '{0}' specified for 'Workers'. The value should be a non-negative integer.</target>
<note>`Workers` is a setting name that shouldn't be localized.</note>
</trans-unit>
<trans-unit id="TestAssembly_AssemblyDiscoveryFailure">
<source>Failed to discover tests from assembly {0}. Reason:{1}</source>
<target state="new">Failed to discover tests from assembly {0}. Reason:{1}</target>
<note></note>
</trans-unit>
</body>
</file>
</xliff>

Просмотреть файл

@ -321,6 +321,11 @@
<target state="new">Invalid value '{0}' specified for 'Workers'. The value should be a non-negative integer.</target>
<note>`Workers` is a setting name that shouldn't be localized.</note>
</trans-unit>
<trans-unit id="TestAssembly_AssemblyDiscoveryFailure">
<source>Failed to discover tests from assembly {0}. Reason:{1}</source>
<target state="new">Failed to discover tests from assembly {0}. Reason:{1}</target>
<note></note>
</trans-unit>
</body>
</file>
</xliff>

Просмотреть файл

@ -321,6 +321,11 @@
<target state="new">Invalid value '{0}' specified for 'Workers'. The value should be a non-negative integer.</target>
<note>`Workers` is a setting name that shouldn't be localized.</note>
</trans-unit>
<trans-unit id="TestAssembly_AssemblyDiscoveryFailure">
<source>Failed to discover tests from assembly {0}. Reason:{1}</source>
<target state="new">Failed to discover tests from assembly {0}. Reason:{1}</target>
<note></note>
</trans-unit>
</body>
</file>
</xliff>

Просмотреть файл

@ -321,6 +321,11 @@
<target state="new">Invalid value '{0}' specified for 'Workers'. The value should be a non-negative integer.</target>
<note>`Workers` is a setting name that shouldn't be localized.</note>
</trans-unit>
<trans-unit id="TestAssembly_AssemblyDiscoveryFailure">
<source>Failed to discover tests from assembly {0}. Reason:{1}</source>
<target state="new">Failed to discover tests from assembly {0}. Reason:{1}</target>
<note></note>
</trans-unit>
</body>
</file>
</xliff>

Просмотреть файл

@ -321,6 +321,11 @@
<target state="new">Invalid value '{0}' specified for 'Workers'. The value should be a non-negative integer.</target>
<note>`Workers` is a setting name that shouldn't be localized.</note>
</trans-unit>
<trans-unit id="TestAssembly_AssemblyDiscoveryFailure">
<source>Failed to discover tests from assembly {0}. Reason:{1}</source>
<target state="new">Failed to discover tests from assembly {0}. Reason:{1}</target>
<note></note>
</trans-unit>
</body>
</file>
</xliff>

Просмотреть файл

@ -321,6 +321,11 @@
<target state="new">Invalid value '{0}' specified for 'Workers'. The value should be a non-negative integer.</target>
<note>`Workers` is a setting name that shouldn't be localized.</note>
</trans-unit>
<trans-unit id="TestAssembly_AssemblyDiscoveryFailure">
<source>Failed to discover tests from assembly {0}. Reason:{1}</source>
<target state="new">Failed to discover tests from assembly {0}. Reason:{1}</target>
<note></note>
</trans-unit>
</body>
</file>
</xliff>

Просмотреть файл

@ -321,6 +321,11 @@
<target state="new">Invalid value '{0}' specified for 'Workers'. The value should be a non-negative integer.</target>
<note>`Workers` is a setting name that shouldn't be localized.</note>
</trans-unit>
<trans-unit id="TestAssembly_AssemblyDiscoveryFailure">
<source>Failed to discover tests from assembly {0}. Reason:{1}</source>
<target state="new">Failed to discover tests from assembly {0}. Reason:{1}</target>
<note></note>
</trans-unit>
</body>
</file>
</xliff>

Просмотреть файл

@ -321,6 +321,11 @@
<target state="new">Invalid value '{0}' specified for 'Workers'. The value should be a non-negative integer.</target>
<note>`Workers` is a setting name that shouldn't be localized.</note>
</trans-unit>
<trans-unit id="TestAssembly_AssemblyDiscoveryFailure">
<source>Failed to discover tests from assembly {0}. Reason:{1}</source>
<target state="new">Failed to discover tests from assembly {0}. Reason:{1}</target>
<note></note>
</trans-unit>
</body>
</file>
</xliff>

Просмотреть файл

@ -321,6 +321,11 @@
<target state="new">Invalid value '{0}' specified for 'Workers'. The value should be a non-negative integer.</target>
<note>`Workers` is a setting name that shouldn't be localized.</note>
</trans-unit>
<trans-unit id="TestAssembly_AssemblyDiscoveryFailure">
<source>Failed to discover tests from assembly {0}. Reason:{1}</source>
<target state="new">Failed to discover tests from assembly {0}. Reason:{1}</target>
<note></note>
</trans-unit>
</body>
</file>
</xliff>

Просмотреть файл

@ -321,6 +321,11 @@
<target state="new">Invalid value '{0}' specified for 'Workers'. The value should be a non-negative integer.</target>
<note>`Workers` is a setting name that shouldn't be localized.</note>
</trans-unit>
<trans-unit id="TestAssembly_AssemblyDiscoveryFailure">
<source>Failed to discover tests from assembly {0}. Reason:{1}</source>
<target state="new">Failed to discover tests from assembly {0}. Reason:{1}</target>
<note></note>
</trans-unit>
</body>
</file>
</xliff>

Просмотреть файл

@ -78,10 +78,15 @@ namespace Microsoft.VisualStudio.TestPlatform.MSTestAdapter.UnitTests.Discovery
// Also validate that we give a warning when this happens.
Assert.IsNotNull(this.warnings);
var message = string.Format(
var innerMessage = string.Format(
CultureInfo.CurrentCulture,
Resource.TestAssembly_FileDoesNotExist,
assemblyName);
var message = string.Format(
CultureInfo.CurrentCulture,
Resource.TestAssembly_AssemblyDiscoveryFailure,
assemblyName,
innerMessage);
CollectionAssert.Contains(this.warnings.ToList(), message);
}