diff --git a/src/vstest.console/Internal/ConsoleLogger.cs b/src/vstest.console/Internal/ConsoleLogger.cs index 35db258aa7..aa81b71189 100644 --- a/src/vstest.console/Internal/ConsoleLogger.cs +++ b/src/vstest.console/Internal/ConsoleLogger.cs @@ -55,6 +55,11 @@ internal class ConsoleLogger : ITestLoggerWithParameters /// internal static bool AppendPrefix; + /// + /// Bool to decide whether progress indicator should be disabled. + /// + internal static bool DisableProgress; + /// /// Uri used to uniquely identify the console logger. /// @@ -75,6 +80,11 @@ internal class ConsoleLogger : ITestLoggerWithParameters /// public const string PrefixParam = "prefix"; + /// + /// Parameter for disabling progress + /// + public const string NoProgressParam = "noprogress"; + #endregion internal enum Verbosity @@ -166,7 +176,7 @@ public void Initialize(TestLoggerEvents events, string testRunDirectory) ConsoleLogger.Output = ConsoleOutput.Instance; } - if (this.progressIndicator == null && !Console.IsOutputRedirected) + if (this.progressIndicator == null && !Console.IsOutputRedirected && !DisableProgress) { // Progress indicator needs to be displayed only for cli experience. this.progressIndicator = new ProgressIndicator(Output, new ConsoleHelper()); @@ -208,6 +218,12 @@ public void Initialize(TestLoggerEvents events, Dictionary param bool.TryParse(prefix, out AppendPrefix); } + var noprogressExists = parameters.TryGetValue(ConsoleLogger.NoProgressParam, out string noprogress); + if (noprogressExists) + { + bool.TryParse(noprogress, out DisableProgress); + } + Initialize(events, String.Empty); } #endregion diff --git a/test/vstest.console.UnitTests/Internal/ConsoleLoggerTests.cs b/test/vstest.console.UnitTests/Internal/ConsoleLoggerTests.cs index 7d17c8bb77..55b9bde34c 100644 --- a/test/vstest.console.UnitTests/Internal/ConsoleLoggerTests.cs +++ b/test/vstest.console.UnitTests/Internal/ConsoleLoggerTests.cs @@ -125,6 +125,21 @@ public void InitializeWithParametersShouldSetPrefixValue() ConsoleLogger.AppendPrefix = false; } + [TestMethod] + public void InitializeWithParametersShouldSetNoProgress() + { + var parameters = new Dictionary(); + + Assert.IsFalse(ConsoleLogger.DisableProgress); + + parameters.Add("noprogress", "true"); + this.consoleLogger.Initialize(new Mock().Object, parameters); + + Assert.IsTrue(ConsoleLogger.DisableProgress); + + ConsoleLogger.DisableProgress = false; + } + [TestMethod] public void TestMessageHandlerShouldThrowExceptionIfEventArgsIsNull() {