diff --git a/TestFx.sln b/TestFx.sln index 5b70d8578b..b2dc827434 100644 --- a/TestFx.sln +++ b/TestFx.sln @@ -21,6 +21,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MSTest.Core", "src\TestFram EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PlatformServices.Desktop", "src\Adapter\PlatformServices.Desktop\PlatformServices.Desktop.csproj", "{B0FCE474-14BC-449A-91EA-A433342C0D63}" EndProject +Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "PlatformServices.Shared", "src\Adapter\PlatformServices.Shared\PlatformServices.Shared.shproj", "{2177C273-AE07-43B3-B87A-443E47A23C5A}" +EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Extension.Desktop", "src\TestFramework\Extension.Desktop\Extension.Desktop.csproj", "{A7EA583B-A2B0-47DA-A058-458F247C7575}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Extension.Core", "src\TestFramework\Extension.Core\Extension.Core.csproj", "{6C9FE494-8315-4667-B3F6-75DC62A62319}" @@ -189,6 +191,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "NetCore", "NetCore", "{D11C EndProject Global GlobalSection(SharedMSBuildProjectFiles) = preSolution + src\Adapter\PlatformServices.Shared\PlatformServices.Shared.projitems*{2177c273-ae07-43b3-b87a-443e47a23c5a}*SharedItemsImports = 13 src\TestFramework\Extension.Shared\Extension.Shared.projitems*{272ca5e1-8e81-4825-9e47-86cce02f700d}*SharedItemsImports = 13 src\TestFramework\Extension.Shared\Extension.Shared.projitems*{df131865-84ee-4540-8112-e88acebdea09}*SharedItemsImports = 4 EndGlobalSection @@ -1180,6 +1183,7 @@ Global {E48AC786-E150-4F41-9A16-32F02E4493D8} = {FF8B1B72-55A1-4FFE-809E-7B79323ED8D0} {7252D9E3-267D-442C-96BC-C73AEF3241D6} = {E48AC786-E150-4F41-9A16-32F02E4493D8} {B0FCE474-14BC-449A-91EA-A433342C0D63} = {24088844-2107-4DB2-8F3F-CBCA94FC4B28} + {2177C273-AE07-43B3-B87A-443E47A23C5A} = {24088844-2107-4DB2-8F3F-CBCA94FC4B28} {A7EA583B-A2B0-47DA-A058-458F247C7575} = {E48AC786-E150-4F41-9A16-32F02E4493D8} {6C9FE494-8315-4667-B3F6-75DC62A62319} = {E48AC786-E150-4F41-9A16-32F02E4493D8} {F2D0BF2C-38F2-4244-80E3-4AAD1C3F4C89} = {A9596292-7E67-4566-9096-143DDAA4E8D8} diff --git a/scripts/build/TestFx.Settings.targets b/scripts/build/TestFx.Settings.targets index 94f2b1ffad..5ceb3bacf0 100644 --- a/scripts/build/TestFx.Settings.targets +++ b/scripts/build/TestFx.Settings.targets @@ -2,9 +2,11 @@ ..\..\ - ..\..\ + $(TestFxRoot) + true - + + diff --git a/scripts/build/TestFx.targets b/scripts/build/TestFx.targets index 3eeed84813..29f227861d 100644 --- a/scripts/build/TestFx.targets +++ b/scripts/build/TestFx.targets @@ -2,7 +2,7 @@ - + ..\..\ @@ -84,7 +84,7 @@ - + @@ -92,4 +92,4 @@ GenerateAssemblyInfoFile;$(CompileDependsOn) - + \ No newline at end of file diff --git a/scripts/common.lib.ps1 b/scripts/common.lib.ps1 index 91785b438c..f7b370a602 100644 --- a/scripts/common.lib.ps1 +++ b/scripts/common.lib.ps1 @@ -22,7 +22,7 @@ $env:TF_PACKAGES_DIR = Join-Path $env:TF_ROOT_DIR "packages" $TF_VERSIONS_FILE = "$PSScriptRoot\build\TestFx.Versions.targets" if ([String]::IsNullOrWhiteSpace($TestPlatformVersion)) { - $TestPlatformVersion = (([XML](Get-Content $TF_VERSIONS_FILE)).Project.PropertyGroup.TestPlatformVersion).InnerText + $TestPlatformVersion = (([XML](Get-Content $TF_VERSIONS_FILE)).Project.PropertyGroup.TestPlatformVersion).InnerText } function Create-Directory([string[]] $path) { @@ -180,64 +180,64 @@ function Write-Log ([string] $message, $messageColor = "Green") { $Host.UI.RawUI.ForegroundColor = $currentColor } -function Install-DotNetCli -{ - Write-Log "Install-DotNetCli: Get dotnet-install.ps1 script..." - $dotnetInstallRemoteScript = "https://raw.githubusercontent.com/dotnet/cli/master/scripts/obtain/dotnet-install.ps1" - $dotnetInstallScript = Join-Path $env:TF_TOOLS_DIR "dotnet-install.ps1" - if (-not (Test-Path $env:TF_TOOLS_DIR)) { - New-Item $env:TF_TOOLS_DIR -Type Directory | Out-Null - } +function Install-DotNetCli { + Write-Log "Install-DotNetCli: Get dotnet-install.ps1 script..." + $dotnetInstallRemoteScript = "https://raw.githubusercontent.com/dotnet/cli/master/scripts/obtain/dotnet-install.ps1" + $dotnetInstallScript = Join-Path $env:TF_TOOLS_DIR "dotnet-install.ps1" + if (-not (Test-Path $env:TF_TOOLS_DIR)) { + New-Item $env:TF_TOOLS_DIR -Type Directory | Out-Null + } - $dotnet_dir= Join-Path $env:TF_TOOLS_DIR "dotnet" + $dotnet_dir = Join-Path $env:TF_TOOLS_DIR "dotnet" - if (-not (Test-Path $dotnet_dir)) { - New-Item $dotnet_dir -Type Directory | Out-Null - } + if (-not (Test-Path $dotnet_dir)) { + New-Item $dotnet_dir -Type Directory | Out-Null + } - (New-Object System.Net.WebClient).DownloadFile($dotnetInstallRemoteScript, $dotnetInstallScript) + (New-Object System.Net.WebClient).DownloadFile($dotnetInstallRemoteScript, $dotnetInstallScript) - if (-not (Test-Path $dotnetInstallScript)) { - Write-Error "Failed to download dotnet install script." - } + if (-not (Test-Path $dotnetInstallScript)) { + Write-Error "Failed to download dotnet install script." + } - Unblock-File $dotnetInstallScript + Unblock-File $dotnetInstallScript - Write-Log "Install-DotNetCli: Get the latest dotnet cli toolset..." - $dotnetInstallPath = Join-Path $env:TF_TOOLS_DIR "dotnet" - New-Item -ItemType directory -Path $dotnetInstallPath -Force | Out-Null - & $dotnetInstallScript -Channel "master" -InstallDir $dotnetInstallPath -Version $env:DOTNET_CLI_VERSION + Write-Log "Install-DotNetCli: Get the latest dotnet cli toolset..." + $dotnetInstallPath = Join-Path $env:TF_TOOLS_DIR "dotnet" + New-Item -ItemType directory -Path $dotnetInstallPath -Force | Out-Null + & $dotnetInstallScript -Channel "master" -InstallDir $dotnetInstallPath -Version $env:DOTNET_CLI_VERSION - & $dotnetInstallScript -InstallDir "$dotnetInstallPath" -Runtime 'dotnet' -Version '2.1.0' -Channel '2.1.0' -Architecture x64 -NoPath - $env:DOTNET_ROOT= $dotnetInstallPath + & $dotnetInstallScript -InstallDir "$dotnetInstallPath" -Runtime 'dotnet' -Version '2.1.0' -Channel '2.1.0' -Architecture x64 -NoPath + $env:DOTNET_ROOT = $dotnetInstallPath - & $dotnetInstallScript -InstallDir "${dotnetInstallPath}_x86" -Runtime 'dotnet' -Version '2.1.0' -Channel '2.1.0' -Architecture x86 -NoPath - ${env:DOTNET_ROOT(x86)} = "${dotnetInstallPath}_x86" + & $dotnetInstallScript -InstallDir "${dotnetInstallPath}_x86" -Runtime 'dotnet' -Version '2.1.0' -Channel '2.1.0' -Architecture x86 -NoPath + ${env:DOTNET_ROOT(x86)} = "${dotnetInstallPath}_x86" - & $dotnetInstallScript -InstallDir "$dotnetInstallPath" -Runtime 'dotnet' -Version '3.1.0' -Channel '3.1.0' -Architecture x64 -NoPath - $env:DOTNET_ROOT= $dotnetInstallPath + & $dotnetInstallScript -InstallDir "$dotnetInstallPath" -Runtime 'dotnet' -Version '3.1.0' -Channel '3.1.0' -Architecture x64 -NoPath + $env:DOTNET_ROOT = $dotnetInstallPath - & $dotnetInstallScript -InstallDir "${dotnetInstallPath}_x86" -Runtime 'dotnet' -Version '3.1.0' -Channel '3.1.0' -Architecture x86 -NoPath - ${env:DOTNET_ROOT(x86)} = "${dotnetInstallPath}_x86" + & $dotnetInstallScript -InstallDir "${dotnetInstallPath}_x86" -Runtime 'dotnet' -Version '3.1.0' -Channel '3.1.0' -Architecture x86 -NoPath + ${env:DOTNET_ROOT(x86)} = "${dotnetInstallPath}_x86" - & $dotnetInstallScript -InstallDir "$dotnetInstallPath" -Runtime 'dotnet' -Version '5.0.1' -Channel '5.0.1' -Architecture x64 -NoPath - $env:DOTNET_ROOT= $dotnetInstallPath + & $dotnetInstallScript -InstallDir "$dotnetInstallPath" -Runtime 'dotnet' -Version '5.0.1' -Channel '5.0.1' -Architecture x64 -NoPath + $env:DOTNET_ROOT = $dotnetInstallPath - & $dotnetInstallScript -InstallDir "${dotnetInstallPath}_x86" -Runtime 'dotnet' -Version '5.0.1' -Channel '5.0.1' -Architecture x86 -NoPath - ${env:DOTNET_ROOT(x86)} = "${dotnetInstallPath}_x86" + & $dotnetInstallScript -InstallDir "${dotnetInstallPath}_x86" -Runtime 'dotnet' -Version '5.0.1' -Channel '5.0.1' -Architecture x86 -NoPath + ${env:DOTNET_ROOT(x86)} = "${dotnetInstallPath}_x86" - $env:DOTNET_MULTILEVEL_LOOKUP=0 + $env:DOTNET_MULTILEVEL_LOOKUP = 0 - "---- dotnet environment variables" - Get-ChildItem "Env:\dotnet_*" + "---- dotnet environment variables" + Get-ChildItem "Env:\dotnet_*" - "`n`n---- x64 dotnet" - & "$env:DOTNET_ROOT\dotnet.exe" --info - - "`n`n---- x86 dotnet" - # avoid erroring out because we don't have the sdk for x86 that global.json requires - try { - & "${env:DOTNET_ROOT(x86)}\dotnet.exe" --info 2> $null - } catch {} - Write-Log "Install-DotNetCli: Complete." + "`n`n---- x64 dotnet" + & "$env:DOTNET_ROOT\dotnet.exe" --info + + "`n`n---- x86 dotnet" + # avoid erroring out because we don't have the sdk for x86 that global.json requires + try { + & "${env:DOTNET_ROOT(x86)}\dotnet.exe" --info 2> $null + } + catch {} + Write-Log "Install-DotNetCli: Complete." } \ No newline at end of file diff --git a/src/Adapter/MSTest.CoreAdapter/Constants.cs b/src/Adapter/MSTest.CoreAdapter/Constants.cs index 80f4f4637b..98a758d912 100644 --- a/src/Adapter/MSTest.CoreAdapter/Constants.cs +++ b/src/Adapter/MSTest.CoreAdapter/Constants.cs @@ -29,7 +29,6 @@ internal static class Constants internal static readonly Uri ExecutorUri = new Uri(ExecutorUriString); #region Test Property registration - internal static readonly TestProperty DescriptionProperty = TestProperty.Register("Description", DescriptionLabel, typeof(string), TestPropertyAttributes.Hidden, typeof(TestCase)); internal static readonly TestProperty WorkItemIdsProperty = TestProperty.Register("WorkItemIds", WorkItemIdsLabel, typeof(string[]), TestPropertyAttributes.Hidden, typeof(TestCase)); diff --git a/src/Adapter/MSTest.CoreAdapter/Discovery/AssemblyEnumerator.cs b/src/Adapter/MSTest.CoreAdapter/Discovery/AssemblyEnumerator.cs index bbb1e42701..4c67d2bad3 100644 --- a/src/Adapter/MSTest.CoreAdapter/Discovery/AssemblyEnumerator.cs +++ b/src/Adapter/MSTest.CoreAdapter/Discovery/AssemblyEnumerator.cs @@ -55,10 +55,9 @@ public override object InitializeLifetimeService() /// /// Enumerates through all types in the assembly in search of valid test methods. /// - /// The assembly file name. - /// Contains warnings if any, that need to be passed back to the caller. - /// A collection of Test Elements. - [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Justification = "Catching a generic exception since it is a requirement to not abort discovery in case of any errors.")] + /// The assembly file name. + /// Contains warnings if any, that need to be passed back to the caller. + /// A collection of Test Elements. internal ICollection EnumerateAssembly(string assemblyFileName, out ICollection warnings) { Debug.Assert(!string.IsNullOrWhiteSpace(assemblyFileName), "Invalid assembly file name."); @@ -73,9 +72,7 @@ internal ICollection EnumerateAssembly(string assemblyFileName, // For normal test assemblies continue loading it in the default context since: // 1. There isn't much benefit in terms of Performance loading the assembly in a Reflection Only context during discovery. // 2. Loading it in Reflection only context entails a bunch of custom logic to identify custom attributes which is over-kill for normal desktop users. - assembly = PlatformServiceProvider.Instance.FileOperations.LoadAssembly( - assemblyFileName, - isReflectionOnly: true); + assembly = PlatformServiceProvider.Instance.FileOperations.LoadAssembly(assemblyFileName, isReflectionOnly: true); } else { diff --git a/src/Adapter/MSTest.CoreAdapter/Discovery/AssemblyEnumeratorWrapper.cs b/src/Adapter/MSTest.CoreAdapter/Discovery/AssemblyEnumeratorWrapper.cs index fb5683726b..2a1d192445 100644 --- a/src/Adapter/MSTest.CoreAdapter/Discovery/AssemblyEnumeratorWrapper.cs +++ b/src/Adapter/MSTest.CoreAdapter/Discovery/AssemblyEnumeratorWrapper.cs @@ -5,7 +5,6 @@ namespace Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.Discovery { using System; using System.Collections.Generic; - using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.IO; using System.Reflection; @@ -22,8 +21,7 @@ internal class AssemblyEnumeratorWrapper /// /// Assembly name for UTF /// - private static readonly AssemblyName UnitTestFrameworkAssemblyName = - typeof(TestMethodAttribute).GetTypeInfo().Assembly.GetName(); + private static readonly AssemblyName UnitTestFrameworkAssemblyName = typeof(TestMethodAttribute).GetTypeInfo().Assembly.GetName(); /// /// Gets test elements from an assembly. @@ -32,12 +30,7 @@ internal class AssemblyEnumeratorWrapper /// The run Settings. /// Contains warnings if any, that need to be passed back to the caller. /// A collection of test elements. - [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Justification = "Catching a generic exception since it is a requirement to not abort discovery in case of any errors.")] - [SuppressMessage("Microsoft.Design", "CA1021:AvoidOutParameters", MessageId = "3#", Justification = "This is only for internal use.")] - internal ICollection GetTests( - string assemblyFileName, - IRunSettings runSettings, - out ICollection warnings) + internal ICollection GetTests(string assemblyFileName, IRunSettings runSettings, out ICollection warnings) { warnings = new List(); @@ -52,16 +45,11 @@ internal ICollection GetTests( { if (!PlatformServiceProvider.Instance.FileOperations.DoesFileExist(fullFilePath)) { - var message = string.Format( - CultureInfo.CurrentCulture, - Resource.TestAssembly_FileDoesNotExist, - fullFilePath); + var message = string.Format(CultureInfo.CurrentCulture, Resource.TestAssembly_FileDoesNotExist, fullFilePath); throw new FileNotFoundException(message); } - if (!PlatformServiceProvider.Instance.TestSource.IsAssemblyReferenced( - UnitTestFrameworkAssemblyName, - fullFilePath)) + if (!PlatformServiceProvider.Instance.TestSource.IsAssemblyReferenced(UnitTestFrameworkAssemblyName, fullFilePath)) { return null; } @@ -71,33 +59,18 @@ internal ICollection GetTests( } catch (FileNotFoundException ex) { - PlatformServiceProvider.Instance.AdapterTraceLogger.LogWarning( - "MSTestDiscoverer.TryGetTests: Failed to discover tests from {0}. Reason:{1}", - fullFilePath, - ex); - - var message = string.Format( - CultureInfo.CurrentCulture, - Resource.TestAssembly_AssemblyDiscoveryFailure, - fullFilePath, - ex.Message); + var message = string.Format(CultureInfo.CurrentCulture, Resource.TestAssembly_AssemblyDiscoveryFailure, fullFilePath, ex.Message); + PlatformServiceProvider.Instance.AdapterTraceLogger.LogWarning($"{nameof(AssemblyEnumeratorWrapper)}.{nameof(this.GetTests)}: {Resource.TestAssembly_AssemblyDiscoveryFailure}", fullFilePath, ex); warnings.Add(message); return null; } catch (ReflectionTypeLoadException ex) { - var message = string.Format( - CultureInfo.CurrentCulture, - Resource.TestAssembly_AssemblyDiscoveryFailure, - fullFilePath, - ex.Message); + var message = string.Format(CultureInfo.CurrentCulture, Resource.TestAssembly_AssemblyDiscoveryFailure, fullFilePath, ex.Message); + PlatformServiceProvider.Instance.AdapterTraceLogger.LogWarning($"{nameof(AssemblyEnumeratorWrapper)}.{nameof(this.GetTests)}: {Resource.TestAssembly_AssemblyDiscoveryFailure}", fullFilePath, ex); + PlatformServiceProvider.Instance.AdapterTraceLogger.LogWarning("Exceptions thrown from the loader: "); warnings.Add(message); - PlatformServiceProvider.Instance.AdapterTraceLogger.LogWarning( - "MSPhoneTestDiscoverer.TryGetTests: Failed to discover tests from {0}. Reason:{1}", - assemblyFileName, - ex); - PlatformServiceProvider.Instance.AdapterTraceLogger.LogWarning("Exceptions thrown from the Loader :"); if (ex.LoaderExceptions != null) { @@ -120,17 +93,9 @@ internal ICollection GetTests( // Discover test doesn't work if there is a managed C++ project in solution // Assembly.Load() fails to load the managed cpp executable, with FileLoadException. It can load the dll // successfully though. This is known CLR issue. - PlatformServiceProvider.Instance.AdapterTraceLogger.LogWarning( - "MSTestDiscoverer.TryGetTests: Failed to discover tests from {0}. Reason:{1}", - assemblyFileName, - ex); - var message = ex is FileNotFoundException fileNotFoundEx - ? fileNotFoundEx.Message - : string.Format( - CultureInfo.CurrentCulture, - Resource.TestAssembly_AssemblyDiscoveryFailure, - fullFilePath, - ex.Message); + PlatformServiceProvider.Instance.AdapterTraceLogger.LogWarning($"{nameof(AssemblyEnumeratorWrapper)}.{nameof(this.GetTests)}: {Resource.TestAssembly_AssemblyDiscoveryFailure}", fullFilePath, ex); + var message = ex is FileNotFoundException fileNotFoundEx ? fileNotFoundEx.Message : string.Format(CultureInfo.CurrentCulture, Resource.TestAssembly_AssemblyDiscoveryFailure, fullFilePath, ex.Message); + warnings.Add(message); return null; } @@ -141,11 +106,10 @@ private ICollection GetTestsInIsolation(string fullFilePath, IR using (var isolationHost = PlatformServiceProvider.Instance.CreateTestSourceHost(fullFilePath, runSettings, frameworkHandle: null)) { // Create an instance of a type defined in adapter so that adapter gets loaded in the child app domain - var assemblyEnumerator = isolationHost.CreateInstanceForType( - typeof(AssemblyEnumerator), new object[] { MSTestSettings.CurrentSettings }) as AssemblyEnumerator; + var assemblyEnumerator = isolationHost.CreateInstanceForType(typeof(AssemblyEnumerator), new object[] { MSTestSettings.CurrentSettings }) as AssemblyEnumerator; return assemblyEnumerator.EnumerateAssembly(fullFilePath, out warnings); } } } -} +} \ No newline at end of file diff --git a/src/Adapter/MSTest.CoreAdapter/Discovery/TypeEnumerator.cs b/src/Adapter/MSTest.CoreAdapter/Discovery/TypeEnumerator.cs index f670606148..5c585a579a 100644 --- a/src/Adapter/MSTest.CoreAdapter/Discovery/TypeEnumerator.cs +++ b/src/Adapter/MSTest.CoreAdapter/Discovery/TypeEnumerator.cs @@ -49,7 +49,6 @@ internal TypeEnumerator(Type type, string assemblyName, ReflectHelper reflectHel /// /// Contains warnings if any, that need to be passed back to the caller. /// list of test cases. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1021:AvoidOutParameters", MessageId = "0#", Justification = "This is only for internal use.")] internal virtual ICollection Enumerate(out ICollection warnings) { warnings = new Collection(); diff --git a/src/Adapter/MSTest.CoreAdapter/Execution/TestMethodRunner.cs b/src/Adapter/MSTest.CoreAdapter/Execution/TestMethodRunner.cs index 30338d7c42..63bc78323c 100644 --- a/src/Adapter/MSTest.CoreAdapter/Execution/TestMethodRunner.cs +++ b/src/Adapter/MSTest.CoreAdapter/Execution/TestMethodRunner.cs @@ -10,10 +10,13 @@ namespace Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.Execution using System.Globalization; using System.Linq; using System.Reflection; + using Extensions; + using Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.Helpers; using Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.ObjectModel; using Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.Interface; + using UTF = Microsoft.VisualStudio.TestTools.UnitTesting; /// @@ -118,7 +121,6 @@ public TestMethodRunner( /// Executes a test /// /// The test results. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Justification = "Catching all exceptions that will be thrown by user code.")] internal UnitTestResult[] Execute() { string initLogs = string.Empty; diff --git a/src/Adapter/MSTest.CoreAdapter/Execution/TypeCache.cs b/src/Adapter/MSTest.CoreAdapter/Execution/TypeCache.cs index f5d4564733..074845f5fc 100644 --- a/src/Adapter/MSTest.CoreAdapter/Execution/TypeCache.cs +++ b/src/Adapter/MSTest.CoreAdapter/Execution/TypeCache.cs @@ -323,7 +323,6 @@ private PropertyInfo ResolveTestContext(Type classType) /// /// The type. /// The instance. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Justification = "Discoverer should continue with remaining sources.")] private TestAssemblyInfo GetAssemblyInfo(Type type) { var assembly = type.GetTypeInfo().Assembly; diff --git a/src/Adapter/MSTest.CoreAdapter/Friends.cs b/src/Adapter/MSTest.CoreAdapter/Friends.cs index fede71cd63..d4224b84e8 100644 --- a/src/Adapter/MSTest.CoreAdapter/Friends.cs +++ b/src/Adapter/MSTest.CoreAdapter/Friends.cs @@ -4,6 +4,6 @@ // Friend assemblies using System.Runtime.CompilerServices; -[assembly: InternalsVisibleTo("Microsoft.VisualStudio.TestPlatform.MSTestAdapter.UnitTests, PublicKey=002400000480000094000000060200000024000052534131000400000100010007d1fa57c4aed9f0a32e84aa0faefd0de9e8fd6aec8f87fb03766c834c99921eb23be79ad9d5dcc1dd9ad236132102900b723cf980957fc4e177108fc607774f29e8320e92ea05ece4e821c0a5efe8f1645c4c0c93c1ab99285d622caa652c1dfad63d745d6f2de5f17e5eaf0fc4963d261c8a12436518206dc093344d5ad293")] -[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c547cac37abd99c8db225ef2f6c8a3602f3b3606cc9891605d02baa56104f4cfc0734aa39b93bf7852f7d9266654753cc297e7d2edfe0bac1cdcf9f717241550e0a7b191195b7667bb4f64bcb8e2121380fd1d9d46ad2d92d2d15605093924cceaf74c4861eff62abf69b9291ed0a340e113be11e6a7d3113e92484cf7045cc7")] -[assembly: InternalsVisibleTo("MSTestAdapter.Smoke.E2ETests, PublicKey=002400000480000094000000060200000024000052534131000400000100010007d1fa57c4aed9f0a32e84aa0faefd0de9e8fd6aec8f87fb03766c834c99921eb23be79ad9d5dcc1dd9ad236132102900b723cf980957fc4e177108fc607774f29e8320e92ea05ece4e821c0a5efe8f1645c4c0c93c1ab99285d622caa652c1dfad63d745d6f2de5f17e5eaf0fc4963d261c8a12436518206dc093344d5ad293")] \ No newline at end of file +[assembly: InternalsVisibleTo(assemblyName: "Microsoft.VisualStudio.TestPlatform.MSTestAdapter.UnitTests, PublicKey=002400000480000094000000060200000024000052534131000400000100010007d1fa57c4aed9f0a32e84aa0faefd0de9e8fd6aec8f87fb03766c834c99921eb23be79ad9d5dcc1dd9ad236132102900b723cf980957fc4e177108fc607774f29e8320e92ea05ece4e821c0a5efe8f1645c4c0c93c1ab99285d622caa652c1dfad63d745d6f2de5f17e5eaf0fc4963d261c8a12436518206dc093344d5ad293")] +[assembly: InternalsVisibleTo(assemblyName: "DynamicProxyGenAssembly2, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c547cac37abd99c8db225ef2f6c8a3602f3b3606cc9891605d02baa56104f4cfc0734aa39b93bf7852f7d9266654753cc297e7d2edfe0bac1cdcf9f717241550e0a7b191195b7667bb4f64bcb8e2121380fd1d9d46ad2d92d2d15605093924cceaf74c4861eff62abf69b9291ed0a340e113be11e6a7d3113e92484cf7045cc7")] +[assembly: InternalsVisibleTo(assemblyName: "MSTestAdapter.Smoke.E2ETests, PublicKey=002400000480000094000000060200000024000052534131000400000100010007d1fa57c4aed9f0a32e84aa0faefd0de9e8fd6aec8f87fb03766c834c99921eb23be79ad9d5dcc1dd9ad236132102900b723cf980957fc4e177108fc607774f29e8320e92ea05ece4e821c0a5efe8f1645c4c0c93c1ab99285d622caa652c1dfad63d745d6f2de5f17e5eaf0fc4963d261c8a12436518206dc093344d5ad293")] \ No newline at end of file diff --git a/src/Adapter/MSTest.CoreAdapter/Helpers/RunSettingsUtilities.cs b/src/Adapter/MSTest.CoreAdapter/Helpers/RunSettingsUtilities.cs index 646effd838..d5ebb0db98 100644 --- a/src/Adapter/MSTest.CoreAdapter/Helpers/RunSettingsUtilities.cs +++ b/src/Adapter/MSTest.CoreAdapter/Helpers/RunSettingsUtilities.cs @@ -5,11 +5,12 @@ namespace Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.Helpers { using System; using System.Collections.Generic; - using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.IO; using System.Xml; + using Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities; + using TestPlatform.ObjectModel; internal class RunSettingsUtilities @@ -36,7 +37,7 @@ internal static XmlReaderSettings ReaderSettings /// If there is no test run parameters section defined in the settingsxml a blank dictionary is returned. internal static Dictionary GetTestRunParameters(string settingsXml) { - var nodeValue = GetNodeValue>(settingsXml, TestAdapter.Constants.TestRunParametersName, TestRunParameters.FromXml); + var nodeValue = GetNodeValue(settingsXml, TestAdapter.Constants.TestRunParametersName, TestRunParameters.FromXml); if (nodeValue == default(Dictionary)) { // Return default. @@ -65,37 +66,38 @@ internal static void ThrowOnHasAttributes(XmlReader reader) } } - [SuppressMessage("Microsoft.Security.Xml", "CA3053:UseXmlSecureResolver", Justification = "XmlReaderSettings.XmlResolver is not available in portable code.")] private static T GetNodeValue(string settingsXml, string nodeName, Func nodeParser) { + if (string.IsNullOrWhiteSpace(settingsXml)) + { + return default(T); + } + // use XmlReader to avoid loading of the plugins in client code (mainly from VS). - if (!string.IsNullOrWhiteSpace(settingsXml)) + using (StringReader stringReader = new StringReader(settingsXml)) { - using (StringReader stringReader = new StringReader(settingsXml)) - { - XmlReader reader = XmlReader.Create(stringReader, ReaderSettings); + XmlReader reader = XmlReader.Create(stringReader, ReaderSettings); - // read to the fist child - XmlReaderUtilities.ReadToRootNode(reader); - reader.ReadToNextElement(); + // read to the fist child + XmlReaderUtilities.ReadToRootNode(reader); + reader.ReadToNextElement(); - // Read till we reach nodeName element or reach EOF - while (!string.Equals(reader.Name, nodeName, StringComparison.OrdinalIgnoreCase) - && - !reader.EOF) - { - reader.SkipToNextElement(); - } + // Read till we reach nodeName element or reach EOF + while (!string.Equals(reader.Name, nodeName, StringComparison.OrdinalIgnoreCase) + && + !reader.EOF) + { + reader.SkipToNextElement(); + } - if (!reader.EOF) - { - // read nodeName element. - return nodeParser(reader); - } + if (!reader.EOF) + { + // read nodeName element. + return nodeParser(reader); } } return default(T); } } -} +} \ No newline at end of file diff --git a/src/Adapter/MSTest.CoreAdapter/MSTestSettings.cs b/src/Adapter/MSTest.CoreAdapter/MSTestSettings.cs index c99d9e7343..a6fd562431 100644 --- a/src/Adapter/MSTest.CoreAdapter/MSTestSettings.cs +++ b/src/Adapter/MSTest.CoreAdapter/MSTestSettings.cs @@ -167,6 +167,11 @@ private set /// The existing settings object. public static void PopulateSettings(MSTestSettings settings) { + if (settings == null) + { + return; + } + CurrentSettings.CaptureDebugTraces = settings.CaptureDebugTraces; CurrentSettings.ForcedLegacyMode = settings.ForcedLegacyMode; CurrentSettings.TestSettingsFile = settings.TestSettingsFile; @@ -243,9 +248,14 @@ public static bool IsLegacyScenario(IMessageLogger logger) /// The xml with the settings passed from the test platform. /// The name of the adapter settings to fetch - Its either MSTest or MSTestV2 /// The settings if found. Null otherwise. - internal static MSTestSettings GetSettings(string runsettingsXml, string settingName) + internal static MSTestSettings GetSettings(string runSettingsXml, string settingName) { - using (var stringReader = new StringReader(runsettingsXml)) + if (string.IsNullOrWhiteSpace(runSettingsXml)) + { + return null; + } + + using (var stringReader = new StringReader(runSettingsXml)) { XmlReader reader = XmlReader.Create(stringReader, XmlRunSettingsUtilities.ReaderSettings); diff --git a/src/Adapter/MSTest.CoreAdapter/ObjectModel/TestMethod.cs b/src/Adapter/MSTest.CoreAdapter/ObjectModel/TestMethod.cs index 9251564a4d..1d0a4f80fc 100644 --- a/src/Adapter/MSTest.CoreAdapter/ObjectModel/TestMethod.cs +++ b/src/Adapter/MSTest.CoreAdapter/ObjectModel/TestMethod.cs @@ -84,7 +84,7 @@ internal TestMethod(string managedTypeName, string managedMethodName, string nam public string FullClassName { get; private set; } /// - /// Gets or sets the declaring class full name. This will be used while getting navigation data. + /// Gets or sets the declaring assembly full name. This will be used while getting navigation data. /// This will be null if AssemblyName is same as DeclaringAssemblyName. /// Reason to set to null in the above case is to minimize the transfer of data across appdomains and not have a performance hit. /// @@ -122,14 +122,10 @@ public string DeclaringClassFullName } } - /// - /// Gets the name of the test assembly - /// + /// public string AssemblyName { get; private set; } - /// - /// Gets a value indicating whether specifies test method is async - /// + /// public bool IsAsync { get; private set; } /// diff --git a/src/Adapter/MSTest.CoreAdapter/ObjectModel/UnitTestResult.cs b/src/Adapter/MSTest.CoreAdapter/ObjectModel/UnitTestResult.cs index 24482a8b5a..c2a4f51a32 100644 --- a/src/Adapter/MSTest.CoreAdapter/ObjectModel/UnitTestResult.cs +++ b/src/Adapter/MSTest.CoreAdapter/ObjectModel/UnitTestResult.cs @@ -14,6 +14,7 @@ namespace Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.ObjectModel using Constants = Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.Constants; [Serializable] + [DebuggerDisplay("{DisplayName} ({Outcome})")] public class UnitTestResult { /// @@ -154,14 +155,14 @@ internal TestResult ToTestResult(TestCase testCase, DateTimeOffset startTime, Da Debug.Assert(testCase != null, "testCase"); var testResult = new TestResult(testCase) - { - DisplayName = this.DisplayName, - Duration = this.Duration, - ErrorMessage = this.ErrorMessage, - ErrorStackTrace = this.ErrorStackTrace, - Outcome = UnitTestOutcomeHelper.ToTestOutcome(this.Outcome, currentSettings), - StartTime = startTime, - EndTime = endTime + { + DisplayName = this.DisplayName, + Duration = this.Duration, + ErrorMessage = this.ErrorMessage, + ErrorStackTrace = this.ErrorStackTrace, + Outcome = UnitTestOutcomeHelper.ToTestOutcome(this.Outcome, currentSettings), + StartTime = startTime, + EndTime = endTime }; testResult.SetPropertyValue(Constants.ExecutionIdProperty, this.ExecutionId); diff --git a/src/Adapter/PlatformServices.Interface/ObjectModel/ITestMethod.cs b/src/Adapter/PlatformServices.Interface/ObjectModel/ITestMethod.cs index 47e10c8a1d..5fa8b3a2b0 100644 --- a/src/Adapter/PlatformServices.Interface/ObjectModel/ITestMethod.cs +++ b/src/Adapter/PlatformServices.Interface/ObjectModel/ITestMethod.cs @@ -19,8 +19,9 @@ public interface ITestMethod string FullClassName { get; } /// - /// Gets the declaring class full name. - /// This will be used for resolving overloads and while getting navigation data. + /// Gets the declaring class full name. This will be used while getting navigation data. + /// This will be null if AssemblyName is same as DeclaringAssemblyName. + /// Reason to set to null in the above case is to minimize the transfer of data across appdomains and not have a performance hit. /// string DeclaringClassFullName { get; } @@ -46,7 +47,7 @@ public interface ITestMethod /// Gets the fully specified method name metadata format. /// /// - /// MethodName`2(ParamTypeA,ParamTypeB,…) + /// MethodName`2(ParamTypeA,ParamTypeB,...) /// string ManagedMethodName { get; } diff --git a/src/Adapter/PlatformServices.Shared/PlatformServices.Shared.projitems b/src/Adapter/PlatformServices.Shared/PlatformServices.Shared.projitems new file mode 100644 index 0000000000..9baba9aead --- /dev/null +++ b/src/Adapter/PlatformServices.Shared/PlatformServices.Shared.projitems @@ -0,0 +1,14 @@ + + + + $(MSBuildAllProjects);$(MSBuildThisFileFullPath) + true + 2177c273-ae07-43b3-b87a-443e47a23c5a + + + UnitTestFramework.Extension.Shared + + + + + \ No newline at end of file diff --git a/src/Adapter/PlatformServices.Shared/PlatformServices.Shared.shproj b/src/Adapter/PlatformServices.Shared/PlatformServices.Shared.shproj new file mode 100644 index 0000000000..40daaa8eab --- /dev/null +++ b/src/Adapter/PlatformServices.Shared/PlatformServices.Shared.shproj @@ -0,0 +1,13 @@ + + + + 2177c273-ae07-43b3-b87a-443e47a23c5a + 14.0 + + + + + + + + \ No newline at end of file diff --git a/src/Package/MSTest.TestAdapter.symbols.nuspec b/src/Package/MSTest.TestAdapter.symbols.nuspec index b5b8c1da88..b134110919 100644 --- a/src/Package/MSTest.TestAdapter.symbols.nuspec +++ b/src/Package/MSTest.TestAdapter.symbols.nuspec @@ -14,17 +14,17 @@ - .NET 4.5.0+ - .NET Core 1.0+ (Universal Windows Apps 10+) (Visual Studio 2017) - ASP.NET Core 1.0+ (Visual Studio 2017) - + https://github.com/microsoft/testfx LICENSE http://go.microsoft.com/fwlink/?LinkID=288859 © Microsoft Corporation. All rights reserved. MSTest TestFramework TestAdapter VisualStudio Unittest MSTestV2 Microsoft - + - - - + + + @@ -58,7 +58,7 @@ - + @@ -69,7 +69,7 @@ - + diff --git a/src/TestFramework/Extension.Shared/Extension.Shared.shproj b/src/TestFramework/Extension.Shared/Extension.Shared.shproj index 9f7ebd4c48..a83b11796c 100644 --- a/src/TestFramework/Extension.Shared/Extension.Shared.shproj +++ b/src/TestFramework/Extension.Shared/Extension.Shared.shproj @@ -7,7 +7,7 @@ - + diff --git a/test/ComponentTests/TestAssets/Directory.Build.targets b/test/ComponentTests/TestAssets/Directory.Build.targets new file mode 100644 index 0000000000..5a5c0f5db7 --- /dev/null +++ b/test/ComponentTests/TestAssets/Directory.Build.targets @@ -0,0 +1,12 @@ + + + + + false + false + + + + + + \ No newline at end of file diff --git a/test/E2ETests/Automation.CLI/Automation.CLI.csproj b/test/E2ETests/Automation.CLI/Automation.CLI.csproj index 1a11e80d67..64ef23565a 100644 --- a/test/E2ETests/Automation.CLI/Automation.CLI.csproj +++ b/test/E2ETests/Automation.CLI/Automation.CLI.csproj @@ -33,7 +33,7 @@ - ..\..\..\packages\Microsoft.TestPlatform.AdapterUtilities.$(TestPlatformVersion)\lib\net45\Microsoft.TestPlatform.AdapterUtilities.dll + ..\..\..\packages\Microsoft.TestPlatform.AdapterUtilities.$(TestPlatformVersion)\lib\netstandard2.0\Microsoft.TestPlatform.AdapterUtilities.dll ..\..\..\packages\Microsoft.TestPlatform.TranslationLayer.$(TestPlatformVersion)\lib\net451\Microsoft.TestPlatform.CommunicationUtilities.dll diff --git a/test/E2ETests/Smoke.E2E.Tests/TestDataSourceExtensibilityTests.cs b/test/E2ETests/Smoke.E2E.Tests/TestDataSourceExtensibilityTests.cs index b23071cd54..fd05f394dc 100644 --- a/test/E2ETests/Smoke.E2E.Tests/TestDataSourceExtensibilityTests.cs +++ b/test/E2ETests/Smoke.E2E.Tests/TestDataSourceExtensibilityTests.cs @@ -15,120 +15,7 @@ public class TestDataSourceExtensibilityTests : CLITestBase public void ExecuteTestDataSourceExtensibilityTests() { this.InvokeVsTestForExecution(new string[] { TestAssembly }); - this.ValidatePassedTestsContain( - "CustomTestDataSourceTestMethod1 (1,2,3)", - "CustomTestDataSourceTestMethod1 (4,5,6)"); + this.ValidatePassedTestsContain("CustomTestDataSourceTestMethod1 (1,2,3)", "CustomTestDataSourceTestMethod1 (4,5,6)"); } - - /* This test needs a reference to "Microsoft.TestPlatform.AdapterUtilities" and "Microsoft.TestPlatform.ObjectModel" NuGet packages. - * It's used to debug FQN changes in test discovery and test execution. - - // using System; - // using System.Collections.Generic; - // using System.Collections.ObjectModel; - // using System.Diagnostics; - // using System.IO; - // using System.Linq; - // using System.Reflection; - // using Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter; - // using Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.Execution; - // using Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.Extensions; - // using Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.ObjectModel; - // using Microsoft.VisualStudio.TestPlatform.ObjectModel; - // using Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter; - // using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; - - [TestMethod] - public void DataSourceTest() - { - var assemblyPath = Path.IsPathRooted(TestAssembly) ? TestAssembly : this.GetAssetFullPath(TestAssembly); - - var unitTestDiscoverer = new UnitTestDiscoverer(); - var logger = new InternalLogger(); - var sink = new InternalSink(); - string runSettingXml = this.GetRunSettingXml(string.Empty, this.GetTestAdapterPath()); - var context = new InternalDiscoveryContext(runSettingXml); - - unitTestDiscoverer.DiscoverTestsInSource(assemblyPath, logger, sink, context); - - var settings = this.GetSettingsWithDebugTrace(true); - var unitTestRunner = new UnitTestRunner(settings); - var testCase = sink.DiscoveredTests.Single(i => i.DisplayName == "CustomTestDataSourceTestMethod1"); - - var unitTestElement = testCase.ToUnitTestElement(assemblyPath); - var testResults = unitTestRunner.RunSingleTest(unitTestElement.TestMethod, new Dictionary()); - - var passedTestResults = testResults.Where(i => i.Outcome == Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.ObjectModel.UnitTestOutcome.Passed).Select(i => i.ToTestResult(testCase, DateTimeOffset.Now, DateTimeOffset.Now, settings)); - - var expectedTests = new[] { "CustomTestDataSourceTestMethod1 (1,2,3)", "CustomTestDataSourceTestMethod1 (4,5,6)" }; - foreach (var test in expectedTests) - { - var testFound = passedTestResults.Any( - p => test.Equals(p.TestCase?.FullyQualifiedName) - || test.Equals(p.DisplayName) - || test.Equals(p.TestCase.DisplayName)); - - Assert.IsTrue(testFound, "Test '{0}' does not appear in passed tests list.", test); - } - } - - private MSTestSettings GetSettingsWithDebugTrace(bool captureDebugTraceValue) - { - string runSettingxml = - @" - - " + captureDebugTraceValue + @" - - "; - - return MSTestSettings.GetSettings(runSettingxml, MSTestSettings.SettingsName); - } - - private class InternalLogger : IMessageLogger - { - public void SendMessage(TestMessageLevel testMessageLevel, string message) - { - Debug.WriteLine($"{testMessageLevel}: {message}"); - } - } - - private class InternalSink : Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter.ITestCaseDiscoverySink - { - private readonly List testCases = new List(); - - public ReadOnlyCollection DiscoveredTests => this.testCases.AsReadOnly(); - - public void SendTestCase(TestCase discoveredTest) => this.testCases.Add(discoveredTest); - } - - private class InternalDiscoveryContext : IDiscoveryContext - { - private readonly IRunSettings runSettings; - - public InternalDiscoveryContext(string runSettings) - { - this.runSettings = new InternalRunSettings(runSettings); - } - - public IRunSettings RunSettings => this.runSettings; - - private class InternalRunSettings : IRunSettings - { - private readonly string runSettings; - - public InternalRunSettings(string runSettings) - { - this.runSettings = runSettings; - } - - public string SettingsXml => this.runSettings; - - public ISettingsProvider GetSettings(string settingsName) - { - throw new System.NotImplementedException(); - } - } - } - */ } -} +} \ No newline at end of file diff --git a/test/E2ETests/Smoke.E2E.Tests/TestProjectFSharpTests.cs b/test/E2ETests/Smoke.E2E.Tests/TestProjectFSharpTests.cs index 48d5b906c9..79c09b82ec 100644 --- a/test/E2ETests/Smoke.E2E.Tests/TestProjectFSharpTests.cs +++ b/test/E2ETests/Smoke.E2E.Tests/TestProjectFSharpTests.cs @@ -15,9 +15,9 @@ public class TestProjectFSharpTests : CLITestBase public void ExecuteCustomTestExtensibilityTests() { this.InvokeVsTestForExecution(new string[] { TestAssembly }); + this.ValidatePassedTestsContain("Test method passing with a . in it"); this.ValidateFailedTestsCount(0); this.ValidatePassedTestsCount(1); - this.ValidatePassedTestsContain("Test method passing with a . in it"); } } } \ No newline at end of file diff --git a/test/E2ETests/TestAssets/DataSourceTestProject/UnitTest1.cs b/test/E2ETests/TestAssets/DataSourceTestProject/UnitTest1.cs index 16c9c03d98..f444c78a00 100644 --- a/test/E2ETests/TestAssets/DataSourceTestProject/UnitTest1.cs +++ b/test/E2ETests/TestAssets/DataSourceTestProject/UnitTest1.cs @@ -14,7 +14,7 @@ public TestContext TestContext set; } - [TestMethod, DataSource("Microsoft.VisualStudio.TestTools.DataSource.CSV", "a.csv", "a#csv", DataAccessMethod.Sequential)] + [TestMethod, DataSource("Microsoft.VisualStudio.TestTools.DataSource.CSV", "|DataDirectory|\\a.csv", "a#csv", DataAccessMethod.Sequential)] public void CsvTestMethod() { Assert.AreEqual(1, TestContext.DataRow["Item1"]); diff --git a/test/E2ETests/TestAssets/Directory.Build.targets b/test/E2ETests/TestAssets/Directory.Build.targets new file mode 100644 index 0000000000..5a5c0f5db7 --- /dev/null +++ b/test/E2ETests/TestAssets/Directory.Build.targets @@ -0,0 +1,12 @@ + + + + + false + false + + + + + + \ No newline at end of file diff --git a/test/UnitTests/MSTest.CoreAdapter.Unit.Tests/Discovery/AssemblyEnumeratorTests.cs b/test/UnitTests/MSTest.CoreAdapter.Unit.Tests/Discovery/AssemblyEnumeratorTests.cs index e01171621a..17a9edda4f 100644 --- a/test/UnitTests/MSTest.CoreAdapter.Unit.Tests/Discovery/AssemblyEnumeratorTests.cs +++ b/test/UnitTests/MSTest.CoreAdapter.Unit.Tests/Discovery/AssemblyEnumeratorTests.cs @@ -57,7 +57,7 @@ public void Cleanup() [TestMethodV1] public void ConstructorShouldPopulateSettings() { - string runSettingxml = + string runSettingsXml = @" True @@ -75,7 +75,7 @@ public void ConstructorShouldPopulateSettings() } }); - MSTestSettings adapterSettings = MSTestSettings.GetSettings(runSettingxml, MSTestSettings.SettingsName); + MSTestSettings adapterSettings = MSTestSettings.GetSettings(runSettingsXml, MSTestSettings.SettingsName); var assemblyEnumerator = new AssemblyEnumerator(adapterSettings); Assert.IsTrue(MSTestSettings.CurrentSettings.ForcedLegacyMode);