From 794dcbb67a434dd70fa4c1df84a28bdf831ad8a6 Mon Sep 17 00:00:00 2001 From: Marco Rossignoli Date: Fri, 10 Feb 2023 17:20:50 +0100 Subject: [PATCH 1/8] add deprecation message --- playground/TestPlatform.Playground/Program.cs | 120 +++++++++--------- src/vstest.console/CommandLine/Executor.cs | 9 +- ...ateDotnetVStestMessageArgumentProcessor.cs | 50 ++++++++ .../Utilities/ArgumentProcessorFactory.cs | 1 + 4 files changed, 118 insertions(+), 62 deletions(-) create mode 100644 src/vstest.console/Processors/ShowDeprecateDotnetVStestMessageArgumentProcessor.cs diff --git a/playground/TestPlatform.Playground/Program.cs b/playground/TestPlatform.Playground/Program.cs index 63e8b72cf6..a4bafc6069 100644 --- a/playground/TestPlatform.Playground/Program.cs +++ b/playground/TestPlatform.Playground/Program.cs @@ -93,68 +93,68 @@ static void Main() //Path.Combine(playground, "MSTest1", "bin", "Debug", "net5.0", "MSTest1.dll"), }; - //// Console mode - //// Uncomment if providing command line parameters is easier for you - //// than converting them to settings, or when you debug command line scenario specifically. - //var settingsFile = Path.GetTempFileName(); - //try - //{ - // File.WriteAllText(settingsFile, sourceSettings); - // var processStartInfo = new ProcessStartInfo - // { - // FileName = console, - // Arguments = $"{string.Join(" ", sources)} --settings:{settingsFile} --listtests", - // UseShellExecute = false, - // }; - // EnvironmentVariables.Variables.ToList().ForEach(processStartInfo.Environment.Add); - // var process = Process.Start(processStartInfo); - // process.WaitForExit(); - // if (process.ExitCode != 0) - // { - // throw new Exception($"Process failed with {process.ExitCode}"); - // } - //} - //finally - //{ - // try { File.Delete(settingsFile); } catch { } - //} - - // design mode - var detailedOutput = true; - var consoleOptions = new ConsoleParameters + // Console mode + // Uncomment if providing command line parameters is easier for you + // than converting them to settings, or when you debug command line scenario specifically. + var settingsFile = Path.GetTempFileName(); + try { - EnvironmentVariables = EnvironmentVariables.Variables, - LogFilePath = Path.Combine(here, "logs", "log.txt"), - TraceLevel = TraceLevel.Off, - }; - var options = new TestPlatformOptions + File.WriteAllText(settingsFile, sourceSettings); + var processStartInfo = new ProcessStartInfo + { + FileName = console, + Arguments = $"{string.Join(" ", sources)} --ShowDeprecateDotnetVSTestMessage", + UseShellExecute = false, + }; + EnvironmentVariables.Variables.ToList().ForEach(processStartInfo.Environment.Add); + var process = Process.Start(processStartInfo); + process.WaitForExit(); + if (process.ExitCode != 0) + { + throw new Exception($"Process failed with {process.ExitCode}"); + } + } + finally { - CollectMetrics = true, - }; - var r = new VsTestConsoleWrapper(console, consoleOptions); - var sessionHandler = new TestSessionHandler(); -#pragma warning disable CS0618 // Type or member is obsolete - //// TestSessions - // r.StartTestSession(sources, sourceSettings, sessionHandler); -#pragma warning restore CS0618 // Type or member is obsolete - var discoveryHandler = new PlaygroundTestDiscoveryHandler(detailedOutput); - var sw = Stopwatch.StartNew(); - // Discovery - r.DiscoverTests(sources, sourceSettings, options, sessionHandler.TestSessionInfo, discoveryHandler); - var discoveryDuration = sw.ElapsedMilliseconds; - Console.WriteLine($"Discovery done in {discoveryDuration} ms"); - sw.Restart(); - // Run with test cases and custom testhost launcher - //r.RunTestsWithCustomTestHost(discoveryHandler.TestCases, sourceSettings, options, sessionHandler.TestSessionInfo, new TestRunHandler(detailedOutput), new DebuggerTestHostLauncher()); - //// Run with test cases and without custom testhost launcher - r.RunTests(discoveryHandler.TestCases, sourceSettings, options, sessionHandler.TestSessionInfo, new TestRunHandler(detailedOutput)); - //// Run with sources and custom testhost launcher - //r.RunTestsWithCustomTestHost(sources, sourceSettings, options, sessionHandler.TestSessionInfo, new TestRunHandler(detailedOutput), new DebuggerTestHostLauncher()); - //// Run with sources - //r.RunTests(sources, sourceSettings, options, sessionHandler.TestSessionInfo, new TestRunHandler(detailedOutput)); - var rd = sw.ElapsedMilliseconds; - Console.WriteLine($"Discovery: {discoveryDuration} ms, Run: {rd} ms, Total: {discoveryDuration + rd} ms"); - Console.WriteLine($"Settings:\n{sourceSettings}"); + try { File.Delete(settingsFile); } catch { } + } + + // design mode + // var detailedOutput = true; + // var consoleOptions = new ConsoleParameters + // { + // EnvironmentVariables = EnvironmentVariables.Variables, + // LogFilePath = Path.Combine(here, "logs", "log.txt"), + // TraceLevel = TraceLevel.Off, + // }; + // var options = new TestPlatformOptions + // { + // CollectMetrics = true, + // }; + // var r = new VsTestConsoleWrapper(console, consoleOptions); + // var sessionHandler = new TestSessionHandler(); + //#pragma warning disable CS0618 // Type or member is obsolete + // //// TestSessions + // // r.StartTestSession(sources, sourceSettings, sessionHandler); + //#pragma warning restore CS0618 // Type or member is obsolete + // var discoveryHandler = new PlaygroundTestDiscoveryHandler(detailedOutput); + // var sw = Stopwatch.StartNew(); + // // Discovery + // r.DiscoverTests(sources, sourceSettings, options, sessionHandler.TestSessionInfo, discoveryHandler); + // var discoveryDuration = sw.ElapsedMilliseconds; + // Console.WriteLine($"Discovery done in {discoveryDuration} ms"); + // sw.Restart(); + // // Run with test cases and custom testhost launcher + // //r.RunTestsWithCustomTestHost(discoveryHandler.TestCases, sourceSettings, options, sessionHandler.TestSessionInfo, new TestRunHandler(detailedOutput), new DebuggerTestHostLauncher()); + // //// Run with test cases and without custom testhost launcher + // r.RunTests(discoveryHandler.TestCases, sourceSettings, options, sessionHandler.TestSessionInfo, new TestRunHandler(detailedOutput)); + // //// Run with sources and custom testhost launcher + // //r.RunTestsWithCustomTestHost(sources, sourceSettings, options, sessionHandler.TestSessionInfo, new TestRunHandler(detailedOutput), new DebuggerTestHostLauncher()); + // //// Run with sources + // //r.RunTests(sources, sourceSettings, options, sessionHandler.TestSessionInfo, new TestRunHandler(detailedOutput)); + // var rd = sw.ElapsedMilliseconds; + // Console.WriteLine($"Discovery: {discoveryDuration} ms, Run: {rd} ms, Total: {discoveryDuration + rd} ms"); + // Console.WriteLine($"Settings:\n{sourceSettings}"); } public class PlaygroundTestDiscoveryHandler : ITestDiscoveryEventsHandler, ITestDiscoveryEventsHandler2 diff --git a/src/vstest.console/CommandLine/Executor.cs b/src/vstest.console/CommandLine/Executor.cs index 954d15fe5a..c6da74c8cd 100644 --- a/src/vstest.console/CommandLine/Executor.cs +++ b/src/vstest.console/CommandLine/Executor.cs @@ -131,7 +131,7 @@ internal int Execute(params string[]? args) // If we're postprocessing we don't need to show the splash if (!ArtifactProcessingPostProcessModeProcessor.ContainsPostProcessCommand(args)) { - PrintSplashScreen(isDiag); + PrintSplashScreen(isDiag, args); } } @@ -434,7 +434,7 @@ private bool ExecuteArgumentProcessor(IArgumentProcessor processor, ref int exit /// /// Displays the Company and Copyright splash title info immediately after launch /// - private void PrintSplashScreen(bool isDiag) + private void PrintSplashScreen(bool isDiag, string[]? args) { string? assemblyVersion = Product.Version; if (!isDiag) @@ -452,6 +452,11 @@ private void PrintSplashScreen(bool isDiag) Output.WriteLine(commandLineBanner, OutputLevel.Information); Output.WriteLine(CommandLineResources.CopyrightCommandLineTitle, OutputLevel.Information); PrintWarningIfRunningEmulatedOnArm64(); + if (ShowDeprecateDotnetVStestMessageArgumentProcessor.ContainsShowDeprecateDotnetVSTestMessageCommand(args)) + { + Output.WriteLine(string.Empty, OutputLevel.Information); + Output.WriteLine("The dotnet vstest command is superseded by dotnet test, which can now be used to run assemblies. See https://aka.ms/dotnet-test.", OutputLevel.Warning); + } Output.WriteLine(string.Empty, OutputLevel.Information); } diff --git a/src/vstest.console/Processors/ShowDeprecateDotnetVStestMessageArgumentProcessor.cs b/src/vstest.console/Processors/ShowDeprecateDotnetVStestMessageArgumentProcessor.cs new file mode 100644 index 0000000000..5e6acc654d --- /dev/null +++ b/src/vstest.console/Processors/ShowDeprecateDotnetVStestMessageArgumentProcessor.cs @@ -0,0 +1,50 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using System; +using System.Linq; + +namespace Microsoft.VisualStudio.TestPlatform.CommandLine.Processors; +internal class ShowDeprecateDotnetVStestMessageArgumentProcessor : IArgumentProcessor +{ + public const string CommandName = "/ShowDeprecateDotnetVSTestMessage"; + private Lazy? _metadata; + private Lazy? _executor; + + public Lazy? Executor + { + get => _executor ??= new Lazy(() => + new ShowDeprecateDotnetVStestMessageProcessorExecutor()); + + set => _executor = value; + } + + public Lazy Metadata + => _metadata ??= new Lazy(() => new ShowDeprecateDotnetVStestMessageProcessorCapabilities()); + + public static bool ContainsShowDeprecateDotnetVSTestMessageCommand(string[]? args) => + args?.Contains("--ShowDeprecateDotnetVSTestMessage", StringComparer.OrdinalIgnoreCase) == true; +} + +internal class ShowDeprecateDotnetVStestMessageProcessorCapabilities : BaseArgumentProcessorCapabilities +{ + public override string CommandName => ShowDeprecateDotnetVStestMessageArgumentProcessor.CommandName; + + public override bool AllowMultiple => false; + + // We put priority at the same level of the argument processor for runsettings passed as argument through cli. + // We'll be sure to run before test run arg processor. + public override ArgumentProcessorPriority Priority => ArgumentProcessorPriority.CliRunSettings; + + public override HelpContentPriority HelpPriority => HelpContentPriority.None; + + // We want to be sure that this command won't show in user help + public override string? HelpContentResourceName => null; +} + +internal class ShowDeprecateDotnetVStestMessageProcessorExecutor : IArgumentExecutor +{ + public ArgumentProcessorResult Execute() => ArgumentProcessorResult.Success; + + public void Initialize(string? argument) { } +} diff --git a/src/vstest.console/Processors/Utilities/ArgumentProcessorFactory.cs b/src/vstest.console/Processors/Utilities/ArgumentProcessorFactory.cs index f42c8170d8..d014395236 100644 --- a/src/vstest.console/Processors/Utilities/ArgumentProcessorFactory.cs +++ b/src/vstest.console/Processors/Utilities/ArgumentProcessorFactory.cs @@ -226,6 +226,7 @@ public IEnumerable GetArgumentProcessorsToAlwaysExecute() new ListSettingsProvidersArgumentProcessor(), new ListFullyQualifiedTestsArgumentProcessor(), new ListTestsTargetPathArgumentProcessor(), + new ShowDeprecateDotnetVStestMessageArgumentProcessor(), new EnvironmentArgumentProcessor() }; From b98d27ff6af1da477d583a9f0fa9a66f168ad225 Mon Sep 17 00:00:00 2001 From: Marco Rossignoli Date: Mon, 13 Feb 2023 15:17:25 +0100 Subject: [PATCH 2/8] add tests --- src/vstest.console/CommandLine/Executor.cs | 2 +- ...ateDotnetVStestMessageArgumentProcessor.cs | 3 -- .../Resources/Resources.Designer.cs | 11 ++++- src/vstest.console/Resources/Resources.resx | 5 +- .../ExecutorUnitTests.cs | 17 +++++++ ...tnetVStestMessageArgumentProcessorTests.cs | 46 +++++++++++++++++++ 6 files changed, 78 insertions(+), 6 deletions(-) create mode 100644 test/vstest.console.UnitTests/Processors/ShowDeprecateDotnetVStestMessageArgumentProcessorTests.cs diff --git a/src/vstest.console/CommandLine/Executor.cs b/src/vstest.console/CommandLine/Executor.cs index c6da74c8cd..89b3044bc0 100644 --- a/src/vstest.console/CommandLine/Executor.cs +++ b/src/vstest.console/CommandLine/Executor.cs @@ -455,7 +455,7 @@ private void PrintSplashScreen(bool isDiag, string[]? args) if (ShowDeprecateDotnetVStestMessageArgumentProcessor.ContainsShowDeprecateDotnetVSTestMessageCommand(args)) { Output.WriteLine(string.Empty, OutputLevel.Information); - Output.WriteLine("The dotnet vstest command is superseded by dotnet test, which can now be used to run assemblies. See https://aka.ms/dotnet-test.", OutputLevel.Warning); + Output.WriteLine(CommandLineResources.VSTestDeprecationMessage, OutputLevel.Warning); } Output.WriteLine(string.Empty, OutputLevel.Information); } diff --git a/src/vstest.console/Processors/ShowDeprecateDotnetVStestMessageArgumentProcessor.cs b/src/vstest.console/Processors/ShowDeprecateDotnetVStestMessageArgumentProcessor.cs index 5e6acc654d..71db32aa9e 100644 --- a/src/vstest.console/Processors/ShowDeprecateDotnetVStestMessageArgumentProcessor.cs +++ b/src/vstest.console/Processors/ShowDeprecateDotnetVStestMessageArgumentProcessor.cs @@ -32,13 +32,10 @@ internal class ShowDeprecateDotnetVStestMessageProcessorCapabilities : BaseArgum public override bool AllowMultiple => false; - // We put priority at the same level of the argument processor for runsettings passed as argument through cli. - // We'll be sure to run before test run arg processor. public override ArgumentProcessorPriority Priority => ArgumentProcessorPriority.CliRunSettings; public override HelpContentPriority HelpPriority => HelpContentPriority.None; - // We want to be sure that this command won't show in user help public override string? HelpContentResourceName => null; } diff --git a/src/vstest.console/Resources/Resources.Designer.cs b/src/vstest.console/Resources/Resources.Designer.cs index 61cecdd3c2..06a734d6be 100644 --- a/src/vstest.console/Resources/Resources.Designer.cs +++ b/src/vstest.console/Resources/Resources.Designer.cs @@ -859,7 +859,7 @@ internal class Resources { } /// - /// Looks up a localized string similar to The directory specified for the procdump executable is not valid and the tool was not found inside environment variables(PROCDUMP_PATH, PATH). + /// Looks up a localized string similar to The directory specified for the procdump executable is not valid and the tool was not found inside environment variables (PROCDUMP_PATH, PATH). /// internal static string InvalidProcDumpToolDirectoryPath { get { @@ -1898,6 +1898,15 @@ internal class Resources { } } + /// + /// Looks up a localized string similar to The dotnet vstest command is superseded by dotnet test, which can now be used to run assemblies. See https://aka.ms/dotnet-test.. + /// + internal static string VSTestDeprecationMessage { + get { + return ResourceManager.GetString("VSTestDeprecationMessage", resourceCulture); + } + } + /// /// Looks up a localized string similar to Logging Vstest Diagnostics in file: {0}. /// diff --git a/src/vstest.console/Resources/Resources.resx b/src/vstest.console/Resources/Resources.resx index bf730bc653..60d401156a 100644 --- a/src/vstest.console/Resources/Resources.resx +++ b/src/vstest.console/Resources/Resources.resx @@ -843,4 +843,7 @@ Error hosting communication channel. - + + The dotnet vstest command is superseded by dotnet test, which can now be used to run assemblies. See https://aka.ms/dotnet-test. + + \ No newline at end of file diff --git a/test/vstest.console.UnitTests/ExecutorUnitTests.cs b/test/vstest.console.UnitTests/ExecutorUnitTests.cs index 12d253e25d..cd8f716dd3 100644 --- a/test/vstest.console.UnitTests/ExecutorUnitTests.cs +++ b/test/vstest.console.UnitTests/ExecutorUnitTests.cs @@ -338,6 +338,23 @@ public void ExecutorShouldPrintRunnerArchitecture() Assert.IsFalse(mockOutput.Messages.Any(message => message.Message!.Contains("vstest.console.exe is running in emulated mode"))); } + [TestMethod] + public void ExecutorShouldPrintDotnetVSTestDeprecationMessage() + { + var mockOutput = new MockOutput(); + Mock processHelper = new(); + processHelper.Setup(x => x.GetCurrentProcessArchitecture()).Returns(PlatformArchitecture.X64); + processHelper.Setup(x => x.GetCurrentProcessId()).Returns(0); + Mock environment = new(); + environment.Setup(x => x.Architecture).Returns(PlatformArchitecture.X64); + + new Executor(mockOutput, _mockTestPlatformEventSource.Object, processHelper.Object, environment.Object).Execute("--ShowDeprecateDotnetVSTestMessage"); + + Assert.AreEqual(6, mockOutput.Messages.Count); + Assert.AreEqual(OutputLevel.Warning, mockOutput.Messages[3].Level); + Assert.AreEqual("The dotnet vstest command is superseded by dotnet test, which can now be used to run assemblies. See https://aka.ms/dotnet-test.", mockOutput.Messages[3].Message); + } + private class MockOutput : IOutput { public List Messages { get; set; } = new List(); diff --git a/test/vstest.console.UnitTests/Processors/ShowDeprecateDotnetVStestMessageArgumentProcessorTests.cs b/test/vstest.console.UnitTests/Processors/ShowDeprecateDotnetVStestMessageArgumentProcessorTests.cs new file mode 100644 index 0000000000..742b1bde6b --- /dev/null +++ b/test/vstest.console.UnitTests/Processors/ShowDeprecateDotnetVStestMessageArgumentProcessorTests.cs @@ -0,0 +1,46 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using Microsoft.VisualStudio.TestPlatform.CommandLine.Processors; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace vstest.console.UnitTests.Processors; + +[TestClass] +[TestCategory("Windows-Review")] +public class ShowDeprecateDotnetVStestMessageArgumentProcessorTests +{ + [TestMethod] + public void ShowDeprecateDotnetVStestMessageProcessorCommandName() + { + Assert.AreEqual("/ShowDeprecateDotnetVSTestMessage", ShowDeprecateDotnetVStestMessageArgumentProcessor.CommandName); + } + + [TestMethod] + public void ShowDeprecateDotnetVStestMessageProcessorCapabilities() + { + ShowDeprecateDotnetVStestMessageProcessorCapabilities showDeprecateDotnetVStestMessageProcessorCapabilities = new(); + Assert.IsNull(showDeprecateDotnetVStestMessageProcessorCapabilities.HelpContentResourceName); + Assert.IsFalse(showDeprecateDotnetVStestMessageProcessorCapabilities.IsAction); + Assert.IsFalse(showDeprecateDotnetVStestMessageProcessorCapabilities.AllowMultiple); + Assert.AreEqual(ArgumentProcessorPriority.CliRunSettings, showDeprecateDotnetVStestMessageProcessorCapabilities.Priority); + Assert.AreEqual(HelpContentPriority.None, showDeprecateDotnetVStestMessageProcessorCapabilities.HelpPriority); + } + + [TestMethod] + public void ShowDeprecateDotnetVStestMessageArgumentProcessorReturnsCorrectTypes() + { + ShowDeprecateDotnetVStestMessageArgumentProcessor showDeprecateDotnetVStestMessageArgumentProcessor = new(); + Assert.IsInstanceOfType(showDeprecateDotnetVStestMessageArgumentProcessor.Executor!.Value, typeof(ShowDeprecateDotnetVStestMessageProcessorExecutor)); + Assert.IsInstanceOfType(showDeprecateDotnetVStestMessageArgumentProcessor.Metadata!.Value, typeof(ShowDeprecateDotnetVStestMessageProcessorCapabilities)); + } + + + [TestMethod] + public void ShowDeprecateDotnetVStestMessageProcessorExecutor_Succeded() + { + ShowDeprecateDotnetVStestMessageProcessorExecutor showDeprecateDotnetVStestMessageProcessorExecutor = new(); + showDeprecateDotnetVStestMessageProcessorExecutor.Initialize("we will ignore the param"); + Assert.AreEqual(ArgumentProcessorResult.Success, showDeprecateDotnetVStestMessageProcessorExecutor.Execute()); + } +} From 17264edd09932cc4e12d68ba372d80e50760a701 Mon Sep 17 00:00:00 2001 From: Marco Rossignoli Date: Mon, 13 Feb 2023 16:02:26 +0100 Subject: [PATCH 3/8] updates --- global.json | 2 +- .../TestPlatform.Playground/Environment.cs | 2 +- playground/TestPlatform.Playground/Program.cs | 120 +++++++++--------- .../Resources/xlf/Resources.cs.xlf | 5 + .../Resources/xlf/Resources.de.xlf | 5 + .../Resources/xlf/Resources.es.xlf | 5 + .../Resources/xlf/Resources.fr.xlf | 5 + .../Resources/xlf/Resources.it.xlf | 5 + .../Resources/xlf/Resources.ja.xlf | 5 + .../Resources/xlf/Resources.ko.xlf | 5 + .../Resources/xlf/Resources.pl.xlf | 5 + .../Resources/xlf/Resources.pt-BR.xlf | 5 + .../Resources/xlf/Resources.ru.xlf | 5 + .../Resources/xlf/Resources.tr.xlf | 5 + .../Resources/xlf/Resources.xlf | 5 + .../Resources/xlf/Resources.zh-Hans.xlf | 5 + .../Resources/xlf/Resources.zh-Hant.xlf | 5 + .../ExecutorUnitTests.cs | 6 +- 18 files changed, 136 insertions(+), 64 deletions(-) diff --git a/global.json b/global.json index 3269eb5ab9..fa10e6e8ce 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "8.0.100-alpha.1.23074.25", + "version": "8.0.0-alpha.1.23058.2", "rollForward": "minor", "allowPrerelease": false, "architecture": "x64" diff --git a/playground/TestPlatform.Playground/Environment.cs b/playground/TestPlatform.Playground/Environment.cs index d7ba86c869..c959e8ea1b 100644 --- a/playground/TestPlatform.Playground/Environment.cs +++ b/playground/TestPlatform.Playground/Environment.cs @@ -11,7 +11,7 @@ internal class EnvironmentVariables { ["VSTEST_CONNECTION_TIMEOUT"] = "999", ["VSTEST_DEBUG_NOBP"] = "1", - ["VSTEST_RUNNER_DEBUG_ATTACHVS"] = "0", + ["VSTEST_RUNNER_DEBUG_ATTACHVS"] = "1", ["VSTEST_HOST_DEBUG_ATTACHVS"] = "0", ["VSTEST_DATACOLLECTOR_DEBUG_ATTACHVS"] = "0", }; diff --git a/playground/TestPlatform.Playground/Program.cs b/playground/TestPlatform.Playground/Program.cs index a4bafc6069..63e8b72cf6 100644 --- a/playground/TestPlatform.Playground/Program.cs +++ b/playground/TestPlatform.Playground/Program.cs @@ -93,68 +93,68 @@ static void Main() //Path.Combine(playground, "MSTest1", "bin", "Debug", "net5.0", "MSTest1.dll"), }; - // Console mode - // Uncomment if providing command line parameters is easier for you - // than converting them to settings, or when you debug command line scenario specifically. - var settingsFile = Path.GetTempFileName(); - try - { - File.WriteAllText(settingsFile, sourceSettings); - var processStartInfo = new ProcessStartInfo - { - FileName = console, - Arguments = $"{string.Join(" ", sources)} --ShowDeprecateDotnetVSTestMessage", - UseShellExecute = false, - }; - EnvironmentVariables.Variables.ToList().ForEach(processStartInfo.Environment.Add); - var process = Process.Start(processStartInfo); - process.WaitForExit(); - if (process.ExitCode != 0) - { - throw new Exception($"Process failed with {process.ExitCode}"); - } - } - finally - { - try { File.Delete(settingsFile); } catch { } - } + //// Console mode + //// Uncomment if providing command line parameters is easier for you + //// than converting them to settings, or when you debug command line scenario specifically. + //var settingsFile = Path.GetTempFileName(); + //try + //{ + // File.WriteAllText(settingsFile, sourceSettings); + // var processStartInfo = new ProcessStartInfo + // { + // FileName = console, + // Arguments = $"{string.Join(" ", sources)} --settings:{settingsFile} --listtests", + // UseShellExecute = false, + // }; + // EnvironmentVariables.Variables.ToList().ForEach(processStartInfo.Environment.Add); + // var process = Process.Start(processStartInfo); + // process.WaitForExit(); + // if (process.ExitCode != 0) + // { + // throw new Exception($"Process failed with {process.ExitCode}"); + // } + //} + //finally + //{ + // try { File.Delete(settingsFile); } catch { } + //} // design mode - // var detailedOutput = true; - // var consoleOptions = new ConsoleParameters - // { - // EnvironmentVariables = EnvironmentVariables.Variables, - // LogFilePath = Path.Combine(here, "logs", "log.txt"), - // TraceLevel = TraceLevel.Off, - // }; - // var options = new TestPlatformOptions - // { - // CollectMetrics = true, - // }; - // var r = new VsTestConsoleWrapper(console, consoleOptions); - // var sessionHandler = new TestSessionHandler(); - //#pragma warning disable CS0618 // Type or member is obsolete - // //// TestSessions - // // r.StartTestSession(sources, sourceSettings, sessionHandler); - //#pragma warning restore CS0618 // Type or member is obsolete - // var discoveryHandler = new PlaygroundTestDiscoveryHandler(detailedOutput); - // var sw = Stopwatch.StartNew(); - // // Discovery - // r.DiscoverTests(sources, sourceSettings, options, sessionHandler.TestSessionInfo, discoveryHandler); - // var discoveryDuration = sw.ElapsedMilliseconds; - // Console.WriteLine($"Discovery done in {discoveryDuration} ms"); - // sw.Restart(); - // // Run with test cases and custom testhost launcher - // //r.RunTestsWithCustomTestHost(discoveryHandler.TestCases, sourceSettings, options, sessionHandler.TestSessionInfo, new TestRunHandler(detailedOutput), new DebuggerTestHostLauncher()); - // //// Run with test cases and without custom testhost launcher - // r.RunTests(discoveryHandler.TestCases, sourceSettings, options, sessionHandler.TestSessionInfo, new TestRunHandler(detailedOutput)); - // //// Run with sources and custom testhost launcher - // //r.RunTestsWithCustomTestHost(sources, sourceSettings, options, sessionHandler.TestSessionInfo, new TestRunHandler(detailedOutput), new DebuggerTestHostLauncher()); - // //// Run with sources - // //r.RunTests(sources, sourceSettings, options, sessionHandler.TestSessionInfo, new TestRunHandler(detailedOutput)); - // var rd = sw.ElapsedMilliseconds; - // Console.WriteLine($"Discovery: {discoveryDuration} ms, Run: {rd} ms, Total: {discoveryDuration + rd} ms"); - // Console.WriteLine($"Settings:\n{sourceSettings}"); + var detailedOutput = true; + var consoleOptions = new ConsoleParameters + { + EnvironmentVariables = EnvironmentVariables.Variables, + LogFilePath = Path.Combine(here, "logs", "log.txt"), + TraceLevel = TraceLevel.Off, + }; + var options = new TestPlatformOptions + { + CollectMetrics = true, + }; + var r = new VsTestConsoleWrapper(console, consoleOptions); + var sessionHandler = new TestSessionHandler(); +#pragma warning disable CS0618 // Type or member is obsolete + //// TestSessions + // r.StartTestSession(sources, sourceSettings, sessionHandler); +#pragma warning restore CS0618 // Type or member is obsolete + var discoveryHandler = new PlaygroundTestDiscoveryHandler(detailedOutput); + var sw = Stopwatch.StartNew(); + // Discovery + r.DiscoverTests(sources, sourceSettings, options, sessionHandler.TestSessionInfo, discoveryHandler); + var discoveryDuration = sw.ElapsedMilliseconds; + Console.WriteLine($"Discovery done in {discoveryDuration} ms"); + sw.Restart(); + // Run with test cases and custom testhost launcher + //r.RunTestsWithCustomTestHost(discoveryHandler.TestCases, sourceSettings, options, sessionHandler.TestSessionInfo, new TestRunHandler(detailedOutput), new DebuggerTestHostLauncher()); + //// Run with test cases and without custom testhost launcher + r.RunTests(discoveryHandler.TestCases, sourceSettings, options, sessionHandler.TestSessionInfo, new TestRunHandler(detailedOutput)); + //// Run with sources and custom testhost launcher + //r.RunTestsWithCustomTestHost(sources, sourceSettings, options, sessionHandler.TestSessionInfo, new TestRunHandler(detailedOutput), new DebuggerTestHostLauncher()); + //// Run with sources + //r.RunTests(sources, sourceSettings, options, sessionHandler.TestSessionInfo, new TestRunHandler(detailedOutput)); + var rd = sw.ElapsedMilliseconds; + Console.WriteLine($"Discovery: {discoveryDuration} ms, Run: {rd} ms, Total: {discoveryDuration + rd} ms"); + Console.WriteLine($"Settings:\n{sourceSettings}"); } public class PlaygroundTestDiscoveryHandler : ITestDiscoveryEventsHandler, ITestDiscoveryEventsHandler2 diff --git a/src/vstest.console/Resources/xlf/Resources.cs.xlf b/src/vstest.console/Resources/xlf/Resources.cs.xlf index ab923b4a13..579863c6cf 100644 --- a/src/vstest.console/Resources/xlf/Resources.cs.xlf +++ b/src/vstest.console/Resources/xlf/Resources.cs.xlf @@ -1234,6 +1234,11 @@ Argument AeDebugger {0} není platný. + + The dotnet vstest command is superseded by dotnet test, which can now be used to run assemblies. See https://aka.ms/dotnet-test. + The dotnet vstest command is superseded by dotnet test, which can now be used to run assemblies. See https://aka.ms/dotnet-test. + + \ No newline at end of file diff --git a/src/vstest.console/Resources/xlf/Resources.de.xlf b/src/vstest.console/Resources/xlf/Resources.de.xlf index dce6530f0f..227225523a 100644 --- a/src/vstest.console/Resources/xlf/Resources.de.xlf +++ b/src/vstest.console/Resources/xlf/Resources.de.xlf @@ -1234,6 +1234,11 @@ Das AeDebugger-Argument "{0}" ist ungültig. + + The dotnet vstest command is superseded by dotnet test, which can now be used to run assemblies. See https://aka.ms/dotnet-test. + The dotnet vstest command is superseded by dotnet test, which can now be used to run assemblies. See https://aka.ms/dotnet-test. + + \ No newline at end of file diff --git a/src/vstest.console/Resources/xlf/Resources.es.xlf b/src/vstest.console/Resources/xlf/Resources.es.xlf index 1fb2463652..c3e380a67b 100644 --- a/src/vstest.console/Resources/xlf/Resources.es.xlf +++ b/src/vstest.console/Resources/xlf/Resources.es.xlf @@ -1237,6 +1237,11 @@ El argumento AeDebugger '{0}' no es válido. + + The dotnet vstest command is superseded by dotnet test, which can now be used to run assemblies. See https://aka.ms/dotnet-test. + The dotnet vstest command is superseded by dotnet test, which can now be used to run assemblies. See https://aka.ms/dotnet-test. + + \ No newline at end of file diff --git a/src/vstest.console/Resources/xlf/Resources.fr.xlf b/src/vstest.console/Resources/xlf/Resources.fr.xlf index 9babf1f2ca..007a6dad0f 100644 --- a/src/vstest.console/Resources/xlf/Resources.fr.xlf +++ b/src/vstest.console/Resources/xlf/Resources.fr.xlf @@ -1234,6 +1234,11 @@ Comportements actuellement pris en charge : L’argument AeDebugger '{0}' n’est pas valide. + + The dotnet vstest command is superseded by dotnet test, which can now be used to run assemblies. See https://aka.ms/dotnet-test. + The dotnet vstest command is superseded by dotnet test, which can now be used to run assemblies. See https://aka.ms/dotnet-test. + + \ No newline at end of file diff --git a/src/vstest.console/Resources/xlf/Resources.it.xlf b/src/vstest.console/Resources/xlf/Resources.it.xlf index 6921e02811..a82393f7e5 100644 --- a/src/vstest.console/Resources/xlf/Resources.it.xlf +++ b/src/vstest.console/Resources/xlf/Resources.it.xlf @@ -1234,6 +1234,11 @@ L'argomento '{0}' di AeDebugger non è valido. + + The dotnet vstest command is superseded by dotnet test, which can now be used to run assemblies. See https://aka.ms/dotnet-test. + The dotnet vstest command is superseded by dotnet test, which can now be used to run assemblies. See https://aka.ms/dotnet-test. + + \ No newline at end of file diff --git a/src/vstest.console/Resources/xlf/Resources.ja.xlf b/src/vstest.console/Resources/xlf/Resources.ja.xlf index bf653b3f16..e850a282f9 100644 --- a/src/vstest.console/Resources/xlf/Resources.ja.xlf +++ b/src/vstest.console/Resources/xlf/Resources.ja.xlf @@ -1234,6 +1234,11 @@ AeDebugger 引数 '{0}' は無効です。 + + The dotnet vstest command is superseded by dotnet test, which can now be used to run assemblies. See https://aka.ms/dotnet-test. + The dotnet vstest command is superseded by dotnet test, which can now be used to run assemblies. See https://aka.ms/dotnet-test. + + \ No newline at end of file diff --git a/src/vstest.console/Resources/xlf/Resources.ko.xlf b/src/vstest.console/Resources/xlf/Resources.ko.xlf index 44a97c0350..4a852da58e 100644 --- a/src/vstest.console/Resources/xlf/Resources.ko.xlf +++ b/src/vstest.console/Resources/xlf/Resources.ko.xlf @@ -1234,6 +1234,11 @@ AeDebugger 인수 '{0}'이(가) 유효하지 않습니다. + + The dotnet vstest command is superseded by dotnet test, which can now be used to run assemblies. See https://aka.ms/dotnet-test. + The dotnet vstest command is superseded by dotnet test, which can now be used to run assemblies. See https://aka.ms/dotnet-test. + + \ No newline at end of file diff --git a/src/vstest.console/Resources/xlf/Resources.pl.xlf b/src/vstest.console/Resources/xlf/Resources.pl.xlf index eb837f02ad..c74e2e7f69 100644 --- a/src/vstest.console/Resources/xlf/Resources.pl.xlf +++ b/src/vstest.console/Resources/xlf/Resources.pl.xlf @@ -1234,6 +1234,11 @@ Argument AeDebugger „{0}” jest nieprawidłowy. + + The dotnet vstest command is superseded by dotnet test, which can now be used to run assemblies. See https://aka.ms/dotnet-test. + The dotnet vstest command is superseded by dotnet test, which can now be used to run assemblies. See https://aka.ms/dotnet-test. + + \ No newline at end of file diff --git a/src/vstest.console/Resources/xlf/Resources.pt-BR.xlf b/src/vstest.console/Resources/xlf/Resources.pt-BR.xlf index 2cdc659caa..f78e26b275 100644 --- a/src/vstest.console/Resources/xlf/Resources.pt-BR.xlf +++ b/src/vstest.console/Resources/xlf/Resources.pt-BR.xlf @@ -1234,6 +1234,11 @@ Altere o prefixo de nível de diagnóstico do agente de console, como mostrado a O argumento do AeDebugger '{0}' não é válido. + + The dotnet vstest command is superseded by dotnet test, which can now be used to run assemblies. See https://aka.ms/dotnet-test. + The dotnet vstest command is superseded by dotnet test, which can now be used to run assemblies. See https://aka.ms/dotnet-test. + + \ No newline at end of file diff --git a/src/vstest.console/Resources/xlf/Resources.ru.xlf b/src/vstest.console/Resources/xlf/Resources.ru.xlf index dd752548ca..0e82c7691a 100644 --- a/src/vstest.console/Resources/xlf/Resources.ru.xlf +++ b/src/vstest.console/Resources/xlf/Resources.ru.xlf @@ -1234,6 +1234,11 @@ Аргумент AeDebugger "{0}" недопустим. + + The dotnet vstest command is superseded by dotnet test, which can now be used to run assemblies. See https://aka.ms/dotnet-test. + The dotnet vstest command is superseded by dotnet test, which can now be used to run assemblies. See https://aka.ms/dotnet-test. + + \ No newline at end of file diff --git a/src/vstest.console/Resources/xlf/Resources.tr.xlf b/src/vstest.console/Resources/xlf/Resources.tr.xlf index be70a709ad..4046a8ee91 100644 --- a/src/vstest.console/Resources/xlf/Resources.tr.xlf +++ b/src/vstest.console/Resources/xlf/Resources.tr.xlf @@ -1234,6 +1234,11 @@ Günlükler için izleme düzeyini aşağıda gösterildiği gibi değiştirin '{0}' AeDebugger bağımsız değişkeni geçerli değil. + + The dotnet vstest command is superseded by dotnet test, which can now be used to run assemblies. See https://aka.ms/dotnet-test. + The dotnet vstest command is superseded by dotnet test, which can now be used to run assemblies. See https://aka.ms/dotnet-test. + + \ No newline at end of file diff --git a/src/vstest.console/Resources/xlf/Resources.xlf b/src/vstest.console/Resources/xlf/Resources.xlf index 7ac5e87920..ea709d6b8d 100644 --- a/src/vstest.console/Resources/xlf/Resources.xlf +++ b/src/vstest.console/Resources/xlf/Resources.xlf @@ -1028,6 +1028,11 @@ Format : TestRunParameters.Parameter(name="<name>", value="<value>") Blame argument '{0}' is not valid. + + The dotnet vstest command is superseded by dotnet test, which can now be used to run assemblies. See https://aka.ms/dotnet-test. + The dotnet vstest command is superseded by dotnet test, which can now be used to run assemblies. See https://aka.ms/dotnet-test. + + \ No newline at end of file diff --git a/src/vstest.console/Resources/xlf/Resources.zh-Hans.xlf b/src/vstest.console/Resources/xlf/Resources.zh-Hans.xlf index cfebb41783..f3a0b8aa55 100644 --- a/src/vstest.console/Resources/xlf/Resources.zh-Hans.xlf +++ b/src/vstest.console/Resources/xlf/Resources.zh-Hans.xlf @@ -1234,6 +1234,11 @@ AeDebugger 参数“{0}”无效。 + + The dotnet vstest command is superseded by dotnet test, which can now be used to run assemblies. See https://aka.ms/dotnet-test. + The dotnet vstest command is superseded by dotnet test, which can now be used to run assemblies. See https://aka.ms/dotnet-test. + + \ No newline at end of file diff --git a/src/vstest.console/Resources/xlf/Resources.zh-Hant.xlf b/src/vstest.console/Resources/xlf/Resources.zh-Hant.xlf index 951b5ae0df..ea2ef7cc2a 100644 --- a/src/vstest.console/Resources/xlf/Resources.zh-Hant.xlf +++ b/src/vstest.console/Resources/xlf/Resources.zh-Hant.xlf @@ -1234,6 +1234,11 @@ AeDebugger 引數 '{0}' 無效。 + + The dotnet vstest command is superseded by dotnet test, which can now be used to run assemblies. See https://aka.ms/dotnet-test. + The dotnet vstest command is superseded by dotnet test, which can now be used to run assemblies. See https://aka.ms/dotnet-test. + + \ No newline at end of file diff --git a/test/vstest.console.UnitTests/ExecutorUnitTests.cs b/test/vstest.console.UnitTests/ExecutorUnitTests.cs index cd8f716dd3..b2116ec2dc 100644 --- a/test/vstest.console.UnitTests/ExecutorUnitTests.cs +++ b/test/vstest.console.UnitTests/ExecutorUnitTests.cs @@ -339,7 +339,9 @@ public void ExecutorShouldPrintRunnerArchitecture() } [TestMethod] - public void ExecutorShouldPrintDotnetVSTestDeprecationMessage() + [DataRow("--ShowDeprecateDotnetVSTestMessage")] + [DataRow("--showdeprecateDotnetvTestMessage")] + public void ExecutorShouldPrintDotnetVSTestDeprecationMessage(string commandLine) { var mockOutput = new MockOutput(); Mock processHelper = new(); @@ -348,7 +350,7 @@ public void ExecutorShouldPrintDotnetVSTestDeprecationMessage() Mock environment = new(); environment.Setup(x => x.Architecture).Returns(PlatformArchitecture.X64); - new Executor(mockOutput, _mockTestPlatformEventSource.Object, processHelper.Object, environment.Object).Execute("--ShowDeprecateDotnetVSTestMessage"); + new Executor(mockOutput, _mockTestPlatformEventSource.Object, processHelper.Object, environment.Object).Execute(commandLine); Assert.AreEqual(6, mockOutput.Messages.Count); Assert.AreEqual(OutputLevel.Warning, mockOutput.Messages[3].Level); From be5dce2f4de4e4362824a88a7f58fc5e4a8bb67c Mon Sep 17 00:00:00 2001 From: Marco Rossignoli Date: Mon, 13 Feb 2023 16:15:11 +0100 Subject: [PATCH 4/8] updates --- global.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/global.json b/global.json index fa10e6e8ce..3269eb5ab9 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "8.0.0-alpha.1.23058.2", + "version": "8.0.100-alpha.1.23074.25", "rollForward": "minor", "allowPrerelease": false, "architecture": "x64" From 7c6dee5bcbb985814fa7ba5dceb1c57d4dbc867a Mon Sep 17 00:00:00 2001 From: Marco Rossignoli Date: Mon, 13 Feb 2023 16:15:36 +0100 Subject: [PATCH 5/8] updates --- playground/TestPlatform.Playground/Environment.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/playground/TestPlatform.Playground/Environment.cs b/playground/TestPlatform.Playground/Environment.cs index c959e8ea1b..d7ba86c869 100644 --- a/playground/TestPlatform.Playground/Environment.cs +++ b/playground/TestPlatform.Playground/Environment.cs @@ -11,7 +11,7 @@ internal class EnvironmentVariables { ["VSTEST_CONNECTION_TIMEOUT"] = "999", ["VSTEST_DEBUG_NOBP"] = "1", - ["VSTEST_RUNNER_DEBUG_ATTACHVS"] = "1", + ["VSTEST_RUNNER_DEBUG_ATTACHVS"] = "0", ["VSTEST_HOST_DEBUG_ATTACHVS"] = "0", ["VSTEST_DATACOLLECTOR_DEBUG_ATTACHVS"] = "0", }; From 728a2173796e506dc8bc13c2e0463135be348bb6 Mon Sep 17 00:00:00 2001 From: Marco Rossignoli Date: Mon, 13 Feb 2023 16:41:50 +0100 Subject: [PATCH 6/8] updates --- src/vstest.console/CommandLine/Executor.cs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/vstest.console/CommandLine/Executor.cs b/src/vstest.console/CommandLine/Executor.cs index 89b3044bc0..dd547de8c8 100644 --- a/src/vstest.console/CommandLine/Executor.cs +++ b/src/vstest.console/CommandLine/Executor.cs @@ -452,12 +452,19 @@ private void PrintSplashScreen(bool isDiag, string[]? args) Output.WriteLine(commandLineBanner, OutputLevel.Information); Output.WriteLine(CommandLineResources.CopyrightCommandLineTitle, OutputLevel.Information); PrintWarningIfRunningEmulatedOnArm64(); + PrintWarningIfInvokedThroughDotnetVSTest(args); + Output.WriteLine(string.Empty, OutputLevel.Information); + } + + /// + /// Display a warning if we're executed through `dotnet vstest` + /// + private void PrintWarningIfInvokedThroughDotnetVSTest(string[]? args) + { if (ShowDeprecateDotnetVStestMessageArgumentProcessor.ContainsShowDeprecateDotnetVSTestMessageCommand(args)) { - Output.WriteLine(string.Empty, OutputLevel.Information); - Output.WriteLine(CommandLineResources.VSTestDeprecationMessage, OutputLevel.Warning); + Output.Warning(false, CommandLineResources.VSTestDeprecationMessage); } - Output.WriteLine(string.Empty, OutputLevel.Information); } /// From 1df0f8584721b88a051eb1006861e53ad983ad97 Mon Sep 17 00:00:00 2001 From: Marco Rossignoli Date: Wed, 15 Feb 2023 09:53:19 +0100 Subject: [PATCH 7/8] fix test --- test/vstest.console.UnitTests/ExecutorUnitTests.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/vstest.console.UnitTests/ExecutorUnitTests.cs b/test/vstest.console.UnitTests/ExecutorUnitTests.cs index b2116ec2dc..2c204e9d0e 100644 --- a/test/vstest.console.UnitTests/ExecutorUnitTests.cs +++ b/test/vstest.console.UnitTests/ExecutorUnitTests.cs @@ -340,7 +340,7 @@ public void ExecutorShouldPrintRunnerArchitecture() [TestMethod] [DataRow("--ShowDeprecateDotnetVSTestMessage")] - [DataRow("--showdeprecateDotnetvTestMessage")] + [DataRow("--showdeprecateDotnetvsTestMessage")] public void ExecutorShouldPrintDotnetVSTestDeprecationMessage(string commandLine) { var mockOutput = new MockOutput(); @@ -352,9 +352,9 @@ public void ExecutorShouldPrintDotnetVSTestDeprecationMessage(string commandLine new Executor(mockOutput, _mockTestPlatformEventSource.Object, processHelper.Object, environment.Object).Execute(commandLine); - Assert.AreEqual(6, mockOutput.Messages.Count); - Assert.AreEqual(OutputLevel.Warning, mockOutput.Messages[3].Level); - Assert.AreEqual("The dotnet vstest command is superseded by dotnet test, which can now be used to run assemblies. See https://aka.ms/dotnet-test.", mockOutput.Messages[3].Message); + Assert.AreEqual(5, mockOutput.Messages.Count); + Assert.AreEqual(OutputLevel.Warning, mockOutput.Messages[2].Level); + Assert.AreEqual("The dotnet vstest command is superseded by dotnet test, which can now be used to run assemblies. See https://aka.ms/dotnet-test.", mockOutput.Messages[2].Message); } private class MockOutput : IOutput From 1415b0bcb65a969a2669b3697462a5c044c8a87c Mon Sep 17 00:00:00 2001 From: Marco Rossignoli Date: Wed, 15 Feb 2023 15:10:52 +0100 Subject: [PATCH 8/8] updates --- .../ExecutorUnitTests.cs | 38 +++++++++---------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/test/vstest.console.UnitTests/ExecutorUnitTests.cs b/test/vstest.console.UnitTests/ExecutorUnitTests.cs index 2c204e9d0e..ef3aa7cbde 100644 --- a/test/vstest.console.UnitTests/ExecutorUnitTests.cs +++ b/test/vstest.console.UnitTests/ExecutorUnitTests.cs @@ -185,6 +185,25 @@ public void ExecuteShouldExitWithErrorOnResponseFileException() Assert.AreEqual(1, exitCode, "Response File Exception execution should exit with error."); } + [TestMethod] + [DataRow("--ShowDeprecateDotnetVSTestMessage")] + [DataRow("--showdeprecateDotnetvsTestMessage")] + public void ExecutorShouldPrintDotnetVSTestDeprecationMessage(string commandLine) + { + var mockOutput = new MockOutput(); + Mock processHelper = new(); + processHelper.Setup(x => x.GetCurrentProcessArchitecture()).Returns(PlatformArchitecture.X64); + processHelper.Setup(x => x.GetCurrentProcessId()).Returns(0); + Mock environment = new(); + environment.Setup(x => x.Architecture).Returns(PlatformArchitecture.X64); + + new Executor(mockOutput, _mockTestPlatformEventSource.Object, processHelper.Object, environment.Object).Execute(commandLine); + + Assert.AreEqual(5, mockOutput.Messages.Count); + Assert.AreEqual(OutputLevel.Warning, mockOutput.Messages[2].Level); + Assert.AreEqual("The dotnet vstest command is superseded by dotnet test, which can now be used to run assemblies. See https://aka.ms/dotnet-test.", mockOutput.Messages[2].Message); + } + [TestMethod] public void ExecuteShouldNotThrowSettingsExceptionButLogOutput() { @@ -338,25 +357,6 @@ public void ExecutorShouldPrintRunnerArchitecture() Assert.IsFalse(mockOutput.Messages.Any(message => message.Message!.Contains("vstest.console.exe is running in emulated mode"))); } - [TestMethod] - [DataRow("--ShowDeprecateDotnetVSTestMessage")] - [DataRow("--showdeprecateDotnetvsTestMessage")] - public void ExecutorShouldPrintDotnetVSTestDeprecationMessage(string commandLine) - { - var mockOutput = new MockOutput(); - Mock processHelper = new(); - processHelper.Setup(x => x.GetCurrentProcessArchitecture()).Returns(PlatformArchitecture.X64); - processHelper.Setup(x => x.GetCurrentProcessId()).Returns(0); - Mock environment = new(); - environment.Setup(x => x.Architecture).Returns(PlatformArchitecture.X64); - - new Executor(mockOutput, _mockTestPlatformEventSource.Object, processHelper.Object, environment.Object).Execute(commandLine); - - Assert.AreEqual(5, mockOutput.Messages.Count); - Assert.AreEqual(OutputLevel.Warning, mockOutput.Messages[2].Level); - Assert.AreEqual("The dotnet vstest command is superseded by dotnet test, which can now be used to run assemblies. See https://aka.ms/dotnet-test.", mockOutput.Messages[2].Message); - } - private class MockOutput : IOutput { public List Messages { get; set; } = new List();