From 4eb1f7686f6f81a31c02cee0b236eefcc5a1fa52 Mon Sep 17 00:00:00 2001 From: Sanan Yuzbashiyev Date: Tue, 26 May 2020 12:32:44 +0200 Subject: [PATCH 01/14] Test space added --- src/Microsoft.TestPlatform.Common/RequestData.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.TestPlatform.Common/RequestData.cs b/src/Microsoft.TestPlatform.Common/RequestData.cs index 14f2ae0033..7909d9a0a3 100644 --- a/src/Microsoft.TestPlatform.Common/RequestData.cs +++ b/src/Microsoft.TestPlatform.Common/RequestData.cs @@ -14,7 +14,7 @@ namespace Microsoft.VisualStudio.TestPlatform.Common public class RequestData : IRequestData { /// - /// The metrics collection. + /// The metrics collection. /// private IMetricsCollection metricsCollection; From fd6cbbf94fe8fb7c2d4dc3827e8f1c831765dc4d Mon Sep 17 00:00:00 2001 From: Sanan Yuzbashiyev Date: Wed, 3 Jun 2020 11:29:21 +0200 Subject: [PATCH 02/14] Exception handler was added to catch AccessDeniedException while trying to create TestResults folder --- .../DataCollectionAttachmentManager.cs | 18 +++++++++++++++--- .../Resources/Resources.Designer.cs | 9 +++++++++ .../Resources/Resources.resx | 3 +++ .../Resources/xlf/Resources.cs.xlf | 10 ++++++++++ .../Resources/xlf/Resources.de.xlf | 10 ++++++++++ .../Resources/xlf/Resources.es.xlf | 10 ++++++++++ .../Resources/xlf/Resources.fr.xlf | 10 ++++++++++ .../Resources/xlf/Resources.it.xlf | 10 ++++++++++ .../Resources/xlf/Resources.ja.xlf | 10 ++++++++++ .../Resources/xlf/Resources.ko.xlf | 10 ++++++++++ .../Resources/xlf/Resources.pl.xlf | 10 ++++++++++ .../Resources/xlf/Resources.pt-BR.xlf | 10 ++++++++++ .../Resources/xlf/Resources.ru.xlf | 10 ++++++++++ .../Resources/xlf/Resources.tr.xlf | 10 ++++++++++ .../Resources/xlf/Resources.xlf | 10 ++++++++++ .../Resources/xlf/Resources.zh-Hans.xlf | 10 ++++++++++ .../Resources/xlf/Resources.zh-Hant.xlf | 10 ++++++++++ .../DataCollectionAttachmentManagerTests.cs | 11 +++++++++++ 18 files changed, 178 insertions(+), 3 deletions(-) diff --git a/src/Microsoft.TestPlatform.Common/DataCollection/DataCollectionAttachmentManager.cs b/src/Microsoft.TestPlatform.Common/DataCollection/DataCollectionAttachmentManager.cs index be447f7fc0..e9505f5baf 100644 --- a/src/Microsoft.TestPlatform.Common/DataCollection/DataCollectionAttachmentManager.cs +++ b/src/Microsoft.TestPlatform.Common/DataCollection/DataCollectionAttachmentManager.cs @@ -17,6 +17,7 @@ namespace Microsoft.VisualStudio.TestPlatform.Common.DataCollector using Microsoft.VisualStudio.TestPlatform.ObjectModel; using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; + using Microsoft.VisualStudio.TestPlatform.Utilities; using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; /// @@ -117,11 +118,22 @@ public void Initialize(SessionId id, string outputDirectory, IMessageSink messag this.SessionOutputDirectory = Path.Combine(absolutePath, id.Id.ToString()); } - // Create the output directory if it doesn't exist. - if (!Directory.Exists(this.SessionOutputDirectory)) + try + { + // Create the output directory if it doesn't exist. + if (!Directory.Exists(this.SessionOutputDirectory)) + { + Directory.CreateDirectory(this.SessionOutputDirectory); + } + } + catch (UnauthorizedAccessException) { - Directory.CreateDirectory(this.SessionOutputDirectory); + string currentFolderPath = Directory.GetParent(outputDirectory).FullName; + string accessDeniedMessage = string.Format(CultureInfo.CurrentCulture, Resources.Resources.AccessDenied, currentFolderPath); + ConsoleOutput.Instance.Error(false, accessDeniedMessage); + throw; } + } /// diff --git a/src/Microsoft.TestPlatform.Common/Resources/Resources.Designer.cs b/src/Microsoft.TestPlatform.Common/Resources/Resources.Designer.cs index 4907235e78..1effd23001 100644 --- a/src/Microsoft.TestPlatform.Common/Resources/Resources.Designer.cs +++ b/src/Microsoft.TestPlatform.Common/Resources/Resources.Designer.cs @@ -60,6 +60,15 @@ internal Resources() { } } + /// + /// Looks up a localized string similar to Access denied while trying to create "TestResults" folder in {0} location. You are getting this exception because you are running vstest.console.exe from a folder which requires administrator rights. To solve the issue : please open command line "As Administrator" or run vstest.console.exe from a folder where you have admin privileges. For more information, please look at the error message :. + /// + internal static string AccessDenied { + get { + return ResourceManager.GetString("AccessDenied", resourceCulture); + } + } + /// /// Looks up a localized string similar to Cancelling the operation as requested.. /// diff --git a/src/Microsoft.TestPlatform.Common/Resources/Resources.resx b/src/Microsoft.TestPlatform.Common/Resources/Resources.resx index 42d99d6496..1bc2e468c6 100644 --- a/src/Microsoft.TestPlatform.Common/Resources/Resources.resx +++ b/src/Microsoft.TestPlatform.Common/Resources/Resources.resx @@ -117,6 +117,9 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + Access denied while trying to create "TestResults" folder in {0} location. You are getting this exception because you are running vstest.console.exe from a folder which requires administrator rights. To solve the issue : please open command line "As Administrator" or run vstest.console.exe from a folder where you have admin privileges. For more information, please look at the error message : + Cancelling the operation as requested. diff --git a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.cs.xlf b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.cs.xlf index fed20b4eb1..6a5e419211 100644 --- a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.cs.xlf +++ b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.cs.xlf @@ -279,6 +279,16 @@ Nepovedlo se načíst rozšíření ze souboru {0}. Další informace získáte pomocí parametru /diag. + + Access denied while trying to create "TestResults" folder in {0} location. You are getting this exception because you are running vstest.console.exe from a folder which requires administrator rights. To solve the issue : please open command line "As Administrator" or run vstest.console.exe from a folder where you have admin privileges. + Access denied while trying to create "TestResults" folder in current location. You are getting this exception because you are running vstest.console.exe from a folder which requires administrator rights. To solve the issue : please open command line "As Administrator" or run vstest.console.exe from a folder where you have admin privileges. + + + + For more information, please look at the error message : + For more information, please look at the error message : + + \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.de.xlf b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.de.xlf index c4db77f1e0..ba9cc0ff53 100644 --- a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.de.xlf +++ b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.de.xlf @@ -279,6 +279,16 @@ Fehler beim Laden von Erweiterungen aus der Datei "{0}". Verwenden Sie "/diag", um weitere Informationen zu erhalten. + + Access denied while trying to create "TestResults" folder in {0} location. You are getting this exception because you are running vstest.console.exe from a folder which requires administrator rights. To solve the issue : please open command line "As Administrator" or run vstest.console.exe from a folder where you have admin privileges. + Access denied while trying to create "TestResults" folder in current location. You are getting this exception because you are running vstest.console.exe from a folder which requires administrator rights. To solve the issue : please open command line "As Administrator" or run vstest.console.exe from a folder where you have admin privileges. + + + + For more information, please look at the error message : + For more information, please look at the error message : + + \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.es.xlf b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.es.xlf index df612b6a04..78d4681cd4 100644 --- a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.es.xlf +++ b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.es.xlf @@ -279,6 +279,16 @@ No se pudieron cargar las extensiones del archivo "{0}". Use /diag para obtener más información. + + Access denied while trying to create "TestResults" folder in {0} location. You are getting this exception because you are running vstest.console.exe from a folder which requires administrator rights. To solve the issue : please open command line "As Administrator" or run vstest.console.exe from a folder where you have admin privileges. + Access denied while trying to create "TestResults" folder in current location. You are getting this exception because you are running vstest.console.exe from a folder which requires administrator rights. To solve the issue : please open command line "As Administrator" or run vstest.console.exe from a folder where you have admin privileges. + + + + For more information, please look at the error message : + For more information, please look at the error message : + + \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.fr.xlf b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.fr.xlf index 2f293f80fc..87b2f16310 100644 --- a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.fr.xlf +++ b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.fr.xlf @@ -279,6 +279,16 @@ Le chargement des extensions à partir du fichier '{0}' a échoué. Pour plus d'informations, utilisez /diag. + + Access denied while trying to create "TestResults" folder in {0} location. You are getting this exception because you are running vstest.console.exe from a folder which requires administrator rights. To solve the issue : please open command line "As Administrator" or run vstest.console.exe from a folder where you have admin privileges. + Access denied while trying to create "TestResults" folder in current location. You are getting this exception because you are running vstest.console.exe from a folder which requires administrator rights. To solve the issue : please open command line "As Administrator" or run vstest.console.exe from a folder where you have admin privileges. + + + + For more information, please look at the error message : + For more information, please look at the error message : + + \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.it.xlf b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.it.xlf index 4cb186f1da..b7a75fbf15 100644 --- a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.it.xlf +++ b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.it.xlf @@ -279,6 +279,16 @@ Non è stato possibile caricare le estensioni dal file '{0}'. Per altre informazioni, usare /diag. + + Access denied while trying to create "TestResults" folder in {0} location. You are getting this exception because you are running vstest.console.exe from a folder which requires administrator rights. To solve the issue : please open command line "As Administrator" or run vstest.console.exe from a folder where you have admin privileges. + Access denied while trying to create "TestResults" folder in current location. You are getting this exception because you are running vstest.console.exe from a folder which requires administrator rights. To solve the issue : please open command line "As Administrator" or run vstest.console.exe from a folder where you have admin privileges. + + + + For more information, please look at the error message : + For more information, please look at the error message : + + \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.ja.xlf b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.ja.xlf index 3b900a7fe5..c7a2c03b35 100644 --- a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.ja.xlf +++ b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.ja.xlf @@ -279,6 +279,16 @@ ファイル '{0}' から拡張機能を読み込めませんでした。詳細な情報を得るには、/diag をご使用ください。 + + Access denied while trying to create "TestResults" folder in {0} location. You are getting this exception because you are running vstest.console.exe from a folder which requires administrator rights. To solve the issue : please open command line "As Administrator" or run vstest.console.exe from a folder where you have admin privileges. + Access denied while trying to create "TestResults" folder in current location. You are getting this exception because you are running vstest.console.exe from a folder which requires administrator rights. To solve the issue : please open command line "As Administrator" or run vstest.console.exe from a folder where you have admin privileges. + + + + For more information, please look at the error message : + For more information, please look at the error message : + + \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.ko.xlf b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.ko.xlf index 6d84c20c02..7a043ba2a7 100644 --- a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.ko.xlf +++ b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.ko.xlf @@ -279,6 +279,16 @@ '{0}' 파일에서 확장을 로드하지 못했습니다. 자세한 내용을 보려면 /diag를 사용하세요. + + Access denied while trying to create "TestResults" folder in {0} location. You are getting this exception because you are running vstest.console.exe from a folder which requires administrator rights. To solve the issue : please open command line "As Administrator" or run vstest.console.exe from a folder where you have admin privileges. + Access denied while trying to create "TestResults" folder in current location. You are getting this exception because you are running vstest.console.exe from a folder which requires administrator rights. To solve the issue : please open command line "As Administrator" or run vstest.console.exe from a folder where you have admin privileges. + + + + For more information, please look at the error message : + For more information, please look at the error message : + + \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.pl.xlf b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.pl.xlf index 7870442226..1326ad653c 100644 --- a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.pl.xlf +++ b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.pl.xlf @@ -279,6 +279,16 @@ Nie można załadować rozszerzeń z pliku „{0}”. Aby uzyskać więcej informacji, użyj opcji /diag. + + Access denied while trying to create "TestResults" folder in {0} location. You are getting this exception because you are running vstest.console.exe from a folder which requires administrator rights. To solve the issue : please open command line "As Administrator" or run vstest.console.exe from a folder where you have admin privileges. + Access denied while trying to create "TestResults" folder in current location. You are getting this exception because you are running vstest.console.exe from a folder which requires administrator rights. To solve the issue : please open command line "As Administrator" or run vstest.console.exe from a folder where you have admin privileges. + + + + For more information, please look at the error message : + For more information, please look at the error message : + + \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.pt-BR.xlf b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.pt-BR.xlf index 750adbb9fa..0f01740a1c 100644 --- a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.pt-BR.xlf +++ b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.pt-BR.xlf @@ -279,6 +279,16 @@ Falha ao carregar as extensões do arquivo '{0}'. Use /diag para obter mais informações. + + Access denied while trying to create "TestResults" folder in {0} location. You are getting this exception because you are running vstest.console.exe from a folder which requires administrator rights. To solve the issue : please open command line "As Administrator" or run vstest.console.exe from a folder where you have admin privileges. + Access denied while trying to create "TestResults" folder in current location. You are getting this exception because you are running vstest.console.exe from a folder which requires administrator rights. To solve the issue : please open command line "As Administrator" or run vstest.console.exe from a folder where you have admin privileges. + + + + For more information, please look at the error message : + For more information, please look at the error message : + + \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.ru.xlf b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.ru.xlf index 16b5ce0949..a2e7d4db8d 100644 --- a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.ru.xlf +++ b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.ru.xlf @@ -279,6 +279,16 @@ Не удалось загрузить расширения из файла "{0}". Для получения дополнительных сведений используйте /diag. + + Access denied while trying to create "TestResults" folder in {0} location. You are getting this exception because you are running vstest.console.exe from a folder which requires administrator rights. To solve the issue : please open command line "As Administrator" or run vstest.console.exe from a folder where you have admin privileges. + Access denied while trying to create "TestResults" folder in current location. You are getting this exception because you are running vstest.console.exe from a folder which requires administrator rights. To solve the issue : please open command line "As Administrator" or run vstest.console.exe from a folder where you have admin privileges. + + + + For more information, please look at the error message : + For more information, please look at the error message : + + \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.tr.xlf b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.tr.xlf index 462c026725..d0c0fa0d51 100644 --- a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.tr.xlf +++ b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.tr.xlf @@ -279,6 +279,16 @@ Uzantılar '{0}' dosyasından yüklenemedi. Daha fazla bilgi için lütfen /diag kullanın. + + Access denied while trying to create "TestResults" folder in {0} location. You are getting this exception because you are running vstest.console.exe from a folder which requires administrator rights. To solve the issue : please open command line "As Administrator" or run vstest.console.exe from a folder where you have admin privileges. + Access denied while trying to create "TestResults" folder in current location. You are getting this exception because you are running vstest.console.exe from a folder which requires administrator rights. To solve the issue : please open command line "As Administrator" or run vstest.console.exe from a folder where you have admin privileges. + + + + For more information, please look at the error message : + For more information, please look at the error message : + + \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.xlf b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.xlf index d1ce2a6073..e72596c340 100644 --- a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.xlf +++ b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.xlf @@ -156,6 +156,16 @@ TestPluginDiscoverer: Failed to load extensions from file '{0}'. Please use /diag for more information. + + Access denied while trying to create "TestResults" folder in {0} location. You are getting this exception because you are running vstest.console.exe from a folder which requires administrator rights. To solve the issue : please open command line "As Administrator" or run vstest.console.exe from a folder where you have admin privileges. + Access denied while trying to create "TestResults" folder in current location. You are getting this exception because you are running vstest.console.exe from a folder which requires administrator rights. To solve the issue : please open command line "As Administrator" or run vstest.console.exe from a folder where you have admin privileges. + + + + For more information, please look at the error message : + For more information, please look at the error message : + + \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.zh-Hans.xlf b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.zh-Hans.xlf index 6c0e2790c0..cfbb0c4f95 100644 --- a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.zh-Hans.xlf +++ b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.zh-Hans.xlf @@ -279,6 +279,16 @@ 未能从文件 "{0}" 加载扩展。有关详细信息,请使用 /diag。 + + Access denied while trying to create "TestResults" folder in {0} location. You are getting this exception because you are running vstest.console.exe from a folder which requires administrator rights. To solve the issue : please open command line "As Administrator" or run vstest.console.exe from a folder where you have admin privileges. + Access denied while trying to create "TestResults" folder in current location. You are getting this exception because you are running vstest.console.exe from a folder which requires administrator rights. To solve the issue : please open command line "As Administrator" or run vstest.console.exe from a folder where you have admin privileges. + + + + For more information, please look at the error message : + For more information, please look at the error message : + + \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.zh-Hant.xlf b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.zh-Hant.xlf index 713186ebb1..bb68b833f7 100644 --- a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.zh-Hant.xlf +++ b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.zh-Hant.xlf @@ -279,6 +279,16 @@ 無法從檔案 '{0}' 載入延伸模組。如需詳細資訊,請使用 /diag。 + + Access denied while trying to create "TestResults" folder in {0} location. You are getting this exception because you are running vstest.console.exe from a folder which requires administrator rights. To solve the issue : please open command line "As Administrator" or run vstest.console.exe from a folder where you have admin privileges. + Access denied while trying to create "TestResults" folder in current location. You are getting this exception because you are running vstest.console.exe from a folder which requires administrator rights. To solve the issue : please open command line "As Administrator" or run vstest.console.exe from a folder where you have admin privileges. + + + + For more information, please look at the error message : + For more information, please look at the error message : + + \ No newline at end of file diff --git a/test/datacollector.UnitTests/DataCollectionAttachmentManagerTests.cs b/test/datacollector.UnitTests/DataCollectionAttachmentManagerTests.cs index 3a5ead9182..fed83dae2b 100644 --- a/test/datacollector.UnitTests/DataCollectionAttachmentManagerTests.cs +++ b/test/datacollector.UnitTests/DataCollectionAttachmentManagerTests.cs @@ -73,6 +73,17 @@ public void InitializeShouldSetCorrectGuidAndOutputPath() Assert.AreEqual(Path.Combine(TempDirectoryPath, this.sessionId.Id.ToString()), this.attachmentManager.SessionOutputDirectory); } + [TestMethod] + public void InitializeShouldNotCreateDirectoryIfNotHaveAccessToFolder() + { + string tempDirectoryPath = Environment.SystemDirectory; + + Assert.ThrowsException(() => + { + this.attachmentManager.Initialize(this.sessionId, tempDirectoryPath, this.messageSink.Object); + }); + } + [TestMethod] public void AddAttachmentShouldNotAddNewFileTransferIfSessionIsNotConfigured() { From 026226a9579e1a7faea604ea2f049d063731b0ac Mon Sep 17 00:00:00 2001 From: Sanan Yuzbashiyev Date: Wed, 3 Jun 2020 11:38:17 +0200 Subject: [PATCH 03/14] Remove unnecessary space --- src/Microsoft.TestPlatform.Common/RequestData.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.TestPlatform.Common/RequestData.cs b/src/Microsoft.TestPlatform.Common/RequestData.cs index 7909d9a0a3..14f2ae0033 100644 --- a/src/Microsoft.TestPlatform.Common/RequestData.cs +++ b/src/Microsoft.TestPlatform.Common/RequestData.cs @@ -14,7 +14,7 @@ namespace Microsoft.VisualStudio.TestPlatform.Common public class RequestData : IRequestData { /// - /// The metrics collection. + /// The metrics collection. /// private IMetricsCollection metricsCollection; From 104ffc0df93599c6a3a35aa48b6790658e17d1e4 Mon Sep 17 00:00:00 2001 From: Sanan Yuzbashiyev Date: Wed, 3 Jun 2020 14:45:53 +0200 Subject: [PATCH 04/14] Deleted unnecessary test. Changed console message and corrected folder path in that message --- .../DataCollectionAttachmentManager.cs | 5 ++--- .../Resources/Resources.Designer.cs | 2 +- .../Resources/Resources.resx | 2 +- .../Resources/xlf/Resources.cs.xlf | 7 +------ .../Resources/xlf/Resources.de.xlf | 7 +------ .../Resources/xlf/Resources.es.xlf | 7 +------ .../Resources/xlf/Resources.fr.xlf | 7 +------ .../Resources/xlf/Resources.it.xlf | 7 +------ .../Resources/xlf/Resources.ja.xlf | 7 +------ .../Resources/xlf/Resources.ko.xlf | 7 +------ .../Resources/xlf/Resources.pl.xlf | 7 +------ .../Resources/xlf/Resources.pt-BR.xlf | 7 +------ .../Resources/xlf/Resources.ru.xlf | 7 +------ .../Resources/xlf/Resources.tr.xlf | 7 +------ .../Resources/xlf/Resources.xlf | 7 +------ .../Resources/xlf/Resources.zh-Hans.xlf | 7 +------ .../Resources/xlf/Resources.zh-Hant.xlf | 7 +------ .../DataCollectionAttachmentManagerTests.cs | 15 +++------------ 18 files changed, 21 insertions(+), 101 deletions(-) diff --git a/src/Microsoft.TestPlatform.Common/DataCollection/DataCollectionAttachmentManager.cs b/src/Microsoft.TestPlatform.Common/DataCollection/DataCollectionAttachmentManager.cs index e9505f5baf..f1606df6b6 100644 --- a/src/Microsoft.TestPlatform.Common/DataCollection/DataCollectionAttachmentManager.cs +++ b/src/Microsoft.TestPlatform.Common/DataCollection/DataCollectionAttachmentManager.cs @@ -126,10 +126,9 @@ public void Initialize(SessionId id, string outputDirectory, IMessageSink messag Directory.CreateDirectory(this.SessionOutputDirectory); } } - catch (UnauthorizedAccessException) + catch (UnauthorizedAccessException accessException) { - string currentFolderPath = Directory.GetParent(outputDirectory).FullName; - string accessDeniedMessage = string.Format(CultureInfo.CurrentCulture, Resources.Resources.AccessDenied, currentFolderPath); + string accessDeniedMessage = string.Format(CultureInfo.CurrentCulture, Resources.Resources.AccessDenied, accessException.Message); ConsoleOutput.Instance.Error(false, accessDeniedMessage); throw; } diff --git a/src/Microsoft.TestPlatform.Common/Resources/Resources.Designer.cs b/src/Microsoft.TestPlatform.Common/Resources/Resources.Designer.cs index 1effd23001..a3242f23b7 100644 --- a/src/Microsoft.TestPlatform.Common/Resources/Resources.Designer.cs +++ b/src/Microsoft.TestPlatform.Common/Resources/Resources.Designer.cs @@ -61,7 +61,7 @@ internal Resources() { } /// - /// Looks up a localized string similar to Access denied while trying to create "TestResults" folder in {0} location. You are getting this exception because you are running vstest.console.exe from a folder which requires administrator rights. To solve the issue : please open command line "As Administrator" or run vstest.console.exe from a folder where you have admin privileges. For more information, please look at the error message :. + /// Looks up a localized string similar to {0}. Access denied while trying to create "TestResults" folder in mentioned location. You are getting this exception because you are running vstest.console.exe from a folder which requires having write access. To solve the issue : please run vstest.console.exe from a folder where you have write privileges to that folder. For more information, please look at the error message :. /// internal static string AccessDenied { get { diff --git a/src/Microsoft.TestPlatform.Common/Resources/Resources.resx b/src/Microsoft.TestPlatform.Common/Resources/Resources.resx index 1bc2e468c6..bec949dab4 100644 --- a/src/Microsoft.TestPlatform.Common/Resources/Resources.resx +++ b/src/Microsoft.TestPlatform.Common/Resources/Resources.resx @@ -118,7 +118,7 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - Access denied while trying to create "TestResults" folder in {0} location. You are getting this exception because you are running vstest.console.exe from a folder which requires administrator rights. To solve the issue : please open command line "As Administrator" or run vstest.console.exe from a folder where you have admin privileges. For more information, please look at the error message : + {0}. Access denied while trying to create "TestResults" folder in mentioned location. You are getting this exception because you are running vstest.console.exe from a folder which requires having write access. To solve the issue : please run vstest.console.exe from a folder where you have write privileges to that folder. For more information, please look at the error message : Cancelling the operation as requested. diff --git a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.cs.xlf b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.cs.xlf index 6a5e419211..31ecb4cf70 100644 --- a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.cs.xlf +++ b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.cs.xlf @@ -280,15 +280,10 @@ - Access denied while trying to create "TestResults" folder in {0} location. You are getting this exception because you are running vstest.console.exe from a folder which requires administrator rights. To solve the issue : please open command line "As Administrator" or run vstest.console.exe from a folder where you have admin privileges. + {0}. Access denied while trying to create "TestResults" folder in mentioned location. You are getting this exception because you are running vstest.console.exe from a folder which requires having write access. To solve the issue : please run vstest.console.exe from a folder where you have write privileges to that folder. For more information, please look at the error message : Access denied while trying to create "TestResults" folder in current location. You are getting this exception because you are running vstest.console.exe from a folder which requires administrator rights. To solve the issue : please open command line "As Administrator" or run vstest.console.exe from a folder where you have admin privileges. - - For more information, please look at the error message : - For more information, please look at the error message : - - \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.de.xlf b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.de.xlf index ba9cc0ff53..d6dddcd094 100644 --- a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.de.xlf +++ b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.de.xlf @@ -280,15 +280,10 @@ - Access denied while trying to create "TestResults" folder in {0} location. You are getting this exception because you are running vstest.console.exe from a folder which requires administrator rights. To solve the issue : please open command line "As Administrator" or run vstest.console.exe from a folder where you have admin privileges. + {0}. Access denied while trying to create "TestResults" folder in mentioned location. You are getting this exception because you are running vstest.console.exe from a folder which requires having write access. To solve the issue : please run vstest.console.exe from a folder where you have write privileges to that folder. For more information, please look at the error message : Access denied while trying to create "TestResults" folder in current location. You are getting this exception because you are running vstest.console.exe from a folder which requires administrator rights. To solve the issue : please open command line "As Administrator" or run vstest.console.exe from a folder where you have admin privileges. - - For more information, please look at the error message : - For more information, please look at the error message : - - \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.es.xlf b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.es.xlf index 78d4681cd4..5ab9ac7fbd 100644 --- a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.es.xlf +++ b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.es.xlf @@ -280,15 +280,10 @@ - Access denied while trying to create "TestResults" folder in {0} location. You are getting this exception because you are running vstest.console.exe from a folder which requires administrator rights. To solve the issue : please open command line "As Administrator" or run vstest.console.exe from a folder where you have admin privileges. + {0}. Access denied while trying to create "TestResults" folder in mentioned location. You are getting this exception because you are running vstest.console.exe from a folder which requires having write access. To solve the issue : please run vstest.console.exe from a folder where you have write privileges to that folder. For more information, please look at the error message : Access denied while trying to create "TestResults" folder in current location. You are getting this exception because you are running vstest.console.exe from a folder which requires administrator rights. To solve the issue : please open command line "As Administrator" or run vstest.console.exe from a folder where you have admin privileges. - - For more information, please look at the error message : - For more information, please look at the error message : - - \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.fr.xlf b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.fr.xlf index 87b2f16310..74e025ae0e 100644 --- a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.fr.xlf +++ b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.fr.xlf @@ -280,15 +280,10 @@ - Access denied while trying to create "TestResults" folder in {0} location. You are getting this exception because you are running vstest.console.exe from a folder which requires administrator rights. To solve the issue : please open command line "As Administrator" or run vstest.console.exe from a folder where you have admin privileges. + {0}. Access denied while trying to create "TestResults" folder in mentioned location. You are getting this exception because you are running vstest.console.exe from a folder which requires having write access. To solve the issue : please run vstest.console.exe from a folder where you have write privileges to that folder. For more information, please look at the error message : Access denied while trying to create "TestResults" folder in current location. You are getting this exception because you are running vstest.console.exe from a folder which requires administrator rights. To solve the issue : please open command line "As Administrator" or run vstest.console.exe from a folder where you have admin privileges. - - For more information, please look at the error message : - For more information, please look at the error message : - - \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.it.xlf b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.it.xlf index b7a75fbf15..04540b4a6e 100644 --- a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.it.xlf +++ b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.it.xlf @@ -280,15 +280,10 @@ - Access denied while trying to create "TestResults" folder in {0} location. You are getting this exception because you are running vstest.console.exe from a folder which requires administrator rights. To solve the issue : please open command line "As Administrator" or run vstest.console.exe from a folder where you have admin privileges. + {0}. Access denied while trying to create "TestResults" folder in mentioned location. You are getting this exception because you are running vstest.console.exe from a folder which requires having write access. To solve the issue : please run vstest.console.exe from a folder where you have write privileges to that folder. For more information, please look at the error message : Access denied while trying to create "TestResults" folder in current location. You are getting this exception because you are running vstest.console.exe from a folder which requires administrator rights. To solve the issue : please open command line "As Administrator" or run vstest.console.exe from a folder where you have admin privileges. - - For more information, please look at the error message : - For more information, please look at the error message : - - \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.ja.xlf b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.ja.xlf index c7a2c03b35..9643502cea 100644 --- a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.ja.xlf +++ b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.ja.xlf @@ -280,15 +280,10 @@ - Access denied while trying to create "TestResults" folder in {0} location. You are getting this exception because you are running vstest.console.exe from a folder which requires administrator rights. To solve the issue : please open command line "As Administrator" or run vstest.console.exe from a folder where you have admin privileges. + {0}. Access denied while trying to create "TestResults" folder in mentioned location. You are getting this exception because you are running vstest.console.exe from a folder which requires having write access. To solve the issue : please run vstest.console.exe from a folder where you have write privileges to that folder. For more information, please look at the error message : Access denied while trying to create "TestResults" folder in current location. You are getting this exception because you are running vstest.console.exe from a folder which requires administrator rights. To solve the issue : please open command line "As Administrator" or run vstest.console.exe from a folder where you have admin privileges. - - For more information, please look at the error message : - For more information, please look at the error message : - - \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.ko.xlf b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.ko.xlf index 7a043ba2a7..7bc77f08eb 100644 --- a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.ko.xlf +++ b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.ko.xlf @@ -280,15 +280,10 @@ - Access denied while trying to create "TestResults" folder in {0} location. You are getting this exception because you are running vstest.console.exe from a folder which requires administrator rights. To solve the issue : please open command line "As Administrator" or run vstest.console.exe from a folder where you have admin privileges. + {0}. Access denied while trying to create "TestResults" folder in mentioned location. You are getting this exception because you are running vstest.console.exe from a folder which requires having write access. To solve the issue : please run vstest.console.exe from a folder where you have write privileges to that folder. For more information, please look at the error message : Access denied while trying to create "TestResults" folder in current location. You are getting this exception because you are running vstest.console.exe from a folder which requires administrator rights. To solve the issue : please open command line "As Administrator" or run vstest.console.exe from a folder where you have admin privileges. - - For more information, please look at the error message : - For more information, please look at the error message : - - \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.pl.xlf b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.pl.xlf index 1326ad653c..fd10033f40 100644 --- a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.pl.xlf +++ b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.pl.xlf @@ -280,15 +280,10 @@ - Access denied while trying to create "TestResults" folder in {0} location. You are getting this exception because you are running vstest.console.exe from a folder which requires administrator rights. To solve the issue : please open command line "As Administrator" or run vstest.console.exe from a folder where you have admin privileges. + {0}. Access denied while trying to create "TestResults" folder in mentioned location. You are getting this exception because you are running vstest.console.exe from a folder which requires having write access. To solve the issue : please run vstest.console.exe from a folder where you have write privileges to that folder. For more information, please look at the error message : Access denied while trying to create "TestResults" folder in current location. You are getting this exception because you are running vstest.console.exe from a folder which requires administrator rights. To solve the issue : please open command line "As Administrator" or run vstest.console.exe from a folder where you have admin privileges. - - For more information, please look at the error message : - For more information, please look at the error message : - - \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.pt-BR.xlf b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.pt-BR.xlf index 0f01740a1c..4d3159a299 100644 --- a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.pt-BR.xlf +++ b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.pt-BR.xlf @@ -280,15 +280,10 @@ - Access denied while trying to create "TestResults" folder in {0} location. You are getting this exception because you are running vstest.console.exe from a folder which requires administrator rights. To solve the issue : please open command line "As Administrator" or run vstest.console.exe from a folder where you have admin privileges. + {0}. Access denied while trying to create "TestResults" folder in mentioned location. You are getting this exception because you are running vstest.console.exe from a folder which requires having write access. To solve the issue : please run vstest.console.exe from a folder where you have write privileges to that folder. For more information, please look at the error message : Access denied while trying to create "TestResults" folder in current location. You are getting this exception because you are running vstest.console.exe from a folder which requires administrator rights. To solve the issue : please open command line "As Administrator" or run vstest.console.exe from a folder where you have admin privileges. - - For more information, please look at the error message : - For more information, please look at the error message : - - \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.ru.xlf b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.ru.xlf index a2e7d4db8d..6bf36c92d7 100644 --- a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.ru.xlf +++ b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.ru.xlf @@ -280,15 +280,10 @@ - Access denied while trying to create "TestResults" folder in {0} location. You are getting this exception because you are running vstest.console.exe from a folder which requires administrator rights. To solve the issue : please open command line "As Administrator" or run vstest.console.exe from a folder where you have admin privileges. + {0}. Access denied while trying to create "TestResults" folder in mentioned location. You are getting this exception because you are running vstest.console.exe from a folder which requires having write access. To solve the issue : please run vstest.console.exe from a folder where you have write privileges to that folder. For more information, please look at the error message : Access denied while trying to create "TestResults" folder in current location. You are getting this exception because you are running vstest.console.exe from a folder which requires administrator rights. To solve the issue : please open command line "As Administrator" or run vstest.console.exe from a folder where you have admin privileges. - - For more information, please look at the error message : - For more information, please look at the error message : - - \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.tr.xlf b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.tr.xlf index d0c0fa0d51..472273c076 100644 --- a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.tr.xlf +++ b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.tr.xlf @@ -280,15 +280,10 @@ - Access denied while trying to create "TestResults" folder in {0} location. You are getting this exception because you are running vstest.console.exe from a folder which requires administrator rights. To solve the issue : please open command line "As Administrator" or run vstest.console.exe from a folder where you have admin privileges. + {0}. Access denied while trying to create "TestResults" folder in mentioned location. You are getting this exception because you are running vstest.console.exe from a folder which requires having write access. To solve the issue : please run vstest.console.exe from a folder where you have write privileges to that folder. For more information, please look at the error message : Access denied while trying to create "TestResults" folder in current location. You are getting this exception because you are running vstest.console.exe from a folder which requires administrator rights. To solve the issue : please open command line "As Administrator" or run vstest.console.exe from a folder where you have admin privileges. - - For more information, please look at the error message : - For more information, please look at the error message : - - \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.xlf b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.xlf index e72596c340..5221994f6b 100644 --- a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.xlf +++ b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.xlf @@ -157,15 +157,10 @@ - Access denied while trying to create "TestResults" folder in {0} location. You are getting this exception because you are running vstest.console.exe from a folder which requires administrator rights. To solve the issue : please open command line "As Administrator" or run vstest.console.exe from a folder where you have admin privileges. + {0}. Access denied while trying to create "TestResults" folder in mentioned location. You are getting this exception because you are running vstest.console.exe from a folder which requires having write access. To solve the issue : please run vstest.console.exe from a folder where you have write privileges to that folder. For more information, please look at the error message : Access denied while trying to create "TestResults" folder in current location. You are getting this exception because you are running vstest.console.exe from a folder which requires administrator rights. To solve the issue : please open command line "As Administrator" or run vstest.console.exe from a folder where you have admin privileges. - - For more information, please look at the error message : - For more information, please look at the error message : - - \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.zh-Hans.xlf b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.zh-Hans.xlf index cfbb0c4f95..7a75335137 100644 --- a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.zh-Hans.xlf +++ b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.zh-Hans.xlf @@ -280,15 +280,10 @@ - Access denied while trying to create "TestResults" folder in {0} location. You are getting this exception because you are running vstest.console.exe from a folder which requires administrator rights. To solve the issue : please open command line "As Administrator" or run vstest.console.exe from a folder where you have admin privileges. + {0}. Access denied while trying to create "TestResults" folder in mentioned location. You are getting this exception because you are running vstest.console.exe from a folder which requires having write access. To solve the issue : please run vstest.console.exe from a folder where you have write privileges to that folder. For more information, please look at the error message : Access denied while trying to create "TestResults" folder in current location. You are getting this exception because you are running vstest.console.exe from a folder which requires administrator rights. To solve the issue : please open command line "As Administrator" or run vstest.console.exe from a folder where you have admin privileges. - - For more information, please look at the error message : - For more information, please look at the error message : - - \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.zh-Hant.xlf b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.zh-Hant.xlf index bb68b833f7..2fc6733866 100644 --- a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.zh-Hant.xlf +++ b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.zh-Hant.xlf @@ -280,15 +280,10 @@ - Access denied while trying to create "TestResults" folder in {0} location. You are getting this exception because you are running vstest.console.exe from a folder which requires administrator rights. To solve the issue : please open command line "As Administrator" or run vstest.console.exe from a folder where you have admin privileges. + {0}. Access denied while trying to create "TestResults" folder in mentioned location. You are getting this exception because you are running vstest.console.exe from a folder which requires having write access. To solve the issue : please run vstest.console.exe from a folder where you have write privileges to that folder. For more information, please look at the error message : Access denied while trying to create "TestResults" folder in current location. You are getting this exception because you are running vstest.console.exe from a folder which requires administrator rights. To solve the issue : please open command line "As Administrator" or run vstest.console.exe from a folder where you have admin privileges. - - For more information, please look at the error message : - For more information, please look at the error message : - - \ No newline at end of file diff --git a/test/datacollector.UnitTests/DataCollectionAttachmentManagerTests.cs b/test/datacollector.UnitTests/DataCollectionAttachmentManagerTests.cs index fed83dae2b..38ced7400c 100644 --- a/test/datacollector.UnitTests/DataCollectionAttachmentManagerTests.cs +++ b/test/datacollector.UnitTests/DataCollectionAttachmentManagerTests.cs @@ -7,6 +7,8 @@ namespace Microsoft.VisualStudio.TestPlatform.Common.DataCollector.UnitTests using System.ComponentModel; using System.IO; using System.Threading; + using System.Security.AccessControl; + using Microsoft.VisualStudio.TestPlatform.Common.DataCollector.Interfaces; using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; @@ -72,18 +74,7 @@ public void InitializeShouldSetCorrectGuidAndOutputPath() Assert.AreEqual(Path.Combine(TempDirectoryPath, this.sessionId.Id.ToString()), this.attachmentManager.SessionOutputDirectory); } - - [TestMethod] - public void InitializeShouldNotCreateDirectoryIfNotHaveAccessToFolder() - { - string tempDirectoryPath = Environment.SystemDirectory; - - Assert.ThrowsException(() => - { - this.attachmentManager.Initialize(this.sessionId, tempDirectoryPath, this.messageSink.Object); - }); - } - + [TestMethod] public void AddAttachmentShouldNotAddNewFileTransferIfSessionIsNotConfigured() { From 2608e881922edd50ad61a2b73f856bea6b220f56 Mon Sep 17 00:00:00 2001 From: Sanan Yuzbashiyev Date: Wed, 3 Jun 2020 14:50:07 +0200 Subject: [PATCH 05/14] Remove unnecessary dot --- .../Resources/Resources.Designer.cs | 2 +- src/Microsoft.TestPlatform.Common/Resources/Resources.resx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.TestPlatform.Common/Resources/Resources.Designer.cs b/src/Microsoft.TestPlatform.Common/Resources/Resources.Designer.cs index a3242f23b7..a47ef652f9 100644 --- a/src/Microsoft.TestPlatform.Common/Resources/Resources.Designer.cs +++ b/src/Microsoft.TestPlatform.Common/Resources/Resources.Designer.cs @@ -61,7 +61,7 @@ internal Resources() { } /// - /// Looks up a localized string similar to {0}. Access denied while trying to create "TestResults" folder in mentioned location. You are getting this exception because you are running vstest.console.exe from a folder which requires having write access. To solve the issue : please run vstest.console.exe from a folder where you have write privileges to that folder. For more information, please look at the error message :. + /// Looks up a localized string similar to {0} Access denied while trying to create "TestResults" folder in mentioned location. You are getting this exception because you are running vstest.console.exe from a folder which requires having write access. To solve the issue : please run vstest.console.exe from a folder where you have write privileges to that folder. For more information, please look at the error message :. /// internal static string AccessDenied { get { diff --git a/src/Microsoft.TestPlatform.Common/Resources/Resources.resx b/src/Microsoft.TestPlatform.Common/Resources/Resources.resx index bec949dab4..27f5bb523e 100644 --- a/src/Microsoft.TestPlatform.Common/Resources/Resources.resx +++ b/src/Microsoft.TestPlatform.Common/Resources/Resources.resx @@ -118,7 +118,7 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - {0}. Access denied while trying to create "TestResults" folder in mentioned location. You are getting this exception because you are running vstest.console.exe from a folder which requires having write access. To solve the issue : please run vstest.console.exe from a folder where you have write privileges to that folder. For more information, please look at the error message : + {0} Access denied while trying to create "TestResults" folder in mentioned location. You are getting this exception because you are running vstest.console.exe from a folder which requires having write access. To solve the issue : please run vstest.console.exe from a folder where you have write privileges to that folder. For more information, please look at the error message : Cancelling the operation as requested. From f8d8aa102d1aa9f7ef577a1dffe24a58c74f7827 Mon Sep 17 00:00:00 2001 From: Sanan Yuzbashiyev Date: Wed, 3 Jun 2020 16:37:49 +0200 Subject: [PATCH 06/14] Removed unnecessary lines and usings and coreccted exception message --- .../Resources/Resources.Designer.cs | 2 +- src/Microsoft.TestPlatform.Common/Resources/Resources.resx | 2 +- .../DataCollectionAttachmentManagerTests.cs | 3 +-- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/Microsoft.TestPlatform.Common/Resources/Resources.Designer.cs b/src/Microsoft.TestPlatform.Common/Resources/Resources.Designer.cs index a47ef652f9..4e54d9b88e 100644 --- a/src/Microsoft.TestPlatform.Common/Resources/Resources.Designer.cs +++ b/src/Microsoft.TestPlatform.Common/Resources/Resources.Designer.cs @@ -61,7 +61,7 @@ internal Resources() { } /// - /// Looks up a localized string similar to {0} Access denied while trying to create "TestResults" folder in mentioned location. You are getting this exception because you are running vstest.console.exe from a folder which requires having write access. To solve the issue : please run vstest.console.exe from a folder where you have write privileges to that folder. For more information, please look at the error message :. + /// Looks up a localized string similar to {0} Access denied while trying to create "TestResults" folder in mentioned location. You are getting this exception because you are running vstest.console.exe from a folder which requires having write access. To solve the issue: please run vstest.console.exe from a folder where you have write privileges. For more information, please look at the error message:. /// internal static string AccessDenied { get { diff --git a/src/Microsoft.TestPlatform.Common/Resources/Resources.resx b/src/Microsoft.TestPlatform.Common/Resources/Resources.resx index 27f5bb523e..3bd129b67e 100644 --- a/src/Microsoft.TestPlatform.Common/Resources/Resources.resx +++ b/src/Microsoft.TestPlatform.Common/Resources/Resources.resx @@ -118,7 +118,7 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - {0} Access denied while trying to create "TestResults" folder in mentioned location. You are getting this exception because you are running vstest.console.exe from a folder which requires having write access. To solve the issue : please run vstest.console.exe from a folder where you have write privileges to that folder. For more information, please look at the error message : + {0} Access denied while trying to create "TestResults" folder in mentioned location. You are getting this exception because you are running vstest.console.exe from a folder which requires having write access. To solve the issue: please run vstest.console.exe from a folder where you have write privileges. For more information, please look at the error message: Cancelling the operation as requested. diff --git a/test/datacollector.UnitTests/DataCollectionAttachmentManagerTests.cs b/test/datacollector.UnitTests/DataCollectionAttachmentManagerTests.cs index 38ced7400c..fbfa442def 100644 --- a/test/datacollector.UnitTests/DataCollectionAttachmentManagerTests.cs +++ b/test/datacollector.UnitTests/DataCollectionAttachmentManagerTests.cs @@ -7,7 +7,6 @@ namespace Microsoft.VisualStudio.TestPlatform.Common.DataCollector.UnitTests using System.ComponentModel; using System.IO; using System.Threading; - using System.Security.AccessControl; using Microsoft.VisualStudio.TestPlatform.Common.DataCollector.Interfaces; @@ -74,7 +73,7 @@ public void InitializeShouldSetCorrectGuidAndOutputPath() Assert.AreEqual(Path.Combine(TempDirectoryPath, this.sessionId.Id.ToString()), this.attachmentManager.SessionOutputDirectory); } - + [TestMethod] public void AddAttachmentShouldNotAddNewFileTransferIfSessionIsNotConfigured() { From 0f6bf185487c98dc6cb143a6423bc167e36c4258 Mon Sep 17 00:00:00 2001 From: Sanan Yuzbashiyev Date: Wed, 3 Jun 2020 18:06:33 +0200 Subject: [PATCH 07/14] Removed unnecessary line --- .../DataCollectionAttachmentManagerTests.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/test/datacollector.UnitTests/DataCollectionAttachmentManagerTests.cs b/test/datacollector.UnitTests/DataCollectionAttachmentManagerTests.cs index fbfa442def..3a5ead9182 100644 --- a/test/datacollector.UnitTests/DataCollectionAttachmentManagerTests.cs +++ b/test/datacollector.UnitTests/DataCollectionAttachmentManagerTests.cs @@ -8,7 +8,6 @@ namespace Microsoft.VisualStudio.TestPlatform.Common.DataCollector.UnitTests using System.IO; using System.Threading; - using Microsoft.VisualStudio.TestPlatform.Common.DataCollector.Interfaces; using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; From d1803c96bd20812cdeeb5429c3a7571af232dfab Mon Sep 17 00:00:00 2001 From: Sanan Yuzbashiyev Date: Thu, 4 Jun 2020 11:05:14 +0200 Subject: [PATCH 08/14] Updating resource files --- .../Resources/xlf/Resources.cs.xlf | 2 +- .../Resources/xlf/Resources.de.xlf | 2 +- .../Resources/xlf/Resources.es.xlf | 2 +- .../Resources/xlf/Resources.fr.xlf | 2 +- .../Resources/xlf/Resources.it.xlf | 2 +- .../Resources/xlf/Resources.ja.xlf | 2 +- .../Resources/xlf/Resources.ko.xlf | 2 +- .../Resources/xlf/Resources.pl.xlf | 2 +- .../Resources/xlf/Resources.pt-BR.xlf | 2 +- .../Resources/xlf/Resources.ru.xlf | 2 +- .../Resources/xlf/Resources.tr.xlf | 2 +- src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.xlf | 2 +- .../Resources/xlf/Resources.zh-Hans.xlf | 2 +- .../Resources/xlf/Resources.zh-Hant.xlf | 2 +- 14 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.cs.xlf b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.cs.xlf index 31ecb4cf70..d133688a44 100644 --- a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.cs.xlf +++ b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.cs.xlf @@ -280,7 +280,7 @@ - {0}. Access denied while trying to create "TestResults" folder in mentioned location. You are getting this exception because you are running vstest.console.exe from a folder which requires having write access. To solve the issue : please run vstest.console.exe from a folder where you have write privileges to that folder. For more information, please look at the error message : + {0} Access denied while trying to create "TestResults" folder in mentioned location. You are getting this exception because you are running vstest.console.exe from a folder which requires having write access. To solve the issue: please run vstest.console.exe from a folder where you have write privileges. For more information, please look at the error message: Access denied while trying to create "TestResults" folder in current location. You are getting this exception because you are running vstest.console.exe from a folder which requires administrator rights. To solve the issue : please open command line "As Administrator" or run vstest.console.exe from a folder where you have admin privileges. diff --git a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.de.xlf b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.de.xlf index d6dddcd094..a32b737dcb 100644 --- a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.de.xlf +++ b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.de.xlf @@ -280,7 +280,7 @@ - {0}. Access denied while trying to create "TestResults" folder in mentioned location. You are getting this exception because you are running vstest.console.exe from a folder which requires having write access. To solve the issue : please run vstest.console.exe from a folder where you have write privileges to that folder. For more information, please look at the error message : + {0} Access denied while trying to create "TestResults" folder in mentioned location. You are getting this exception because you are running vstest.console.exe from a folder which requires having write access. To solve the issue: please run vstest.console.exe from a folder where you have write privileges. For more information, please look at the error message: Access denied while trying to create "TestResults" folder in current location. You are getting this exception because you are running vstest.console.exe from a folder which requires administrator rights. To solve the issue : please open command line "As Administrator" or run vstest.console.exe from a folder where you have admin privileges. diff --git a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.es.xlf b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.es.xlf index 5ab9ac7fbd..3cd6c28c61 100644 --- a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.es.xlf +++ b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.es.xlf @@ -280,7 +280,7 @@ - {0}. Access denied while trying to create "TestResults" folder in mentioned location. You are getting this exception because you are running vstest.console.exe from a folder which requires having write access. To solve the issue : please run vstest.console.exe from a folder where you have write privileges to that folder. For more information, please look at the error message : + {0} Access denied while trying to create "TestResults" folder in mentioned location. You are getting this exception because you are running vstest.console.exe from a folder which requires having write access. To solve the issue: please run vstest.console.exe from a folder where you have write privileges. For more information, please look at the error message: Access denied while trying to create "TestResults" folder in current location. You are getting this exception because you are running vstest.console.exe from a folder which requires administrator rights. To solve the issue : please open command line "As Administrator" or run vstest.console.exe from a folder where you have admin privileges. diff --git a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.fr.xlf b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.fr.xlf index 74e025ae0e..a93ba7f7a7 100644 --- a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.fr.xlf +++ b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.fr.xlf @@ -280,7 +280,7 @@ - {0}. Access denied while trying to create "TestResults" folder in mentioned location. You are getting this exception because you are running vstest.console.exe from a folder which requires having write access. To solve the issue : please run vstest.console.exe from a folder where you have write privileges to that folder. For more information, please look at the error message : + {0} Access denied while trying to create "TestResults" folder in mentioned location. You are getting this exception because you are running vstest.console.exe from a folder which requires having write access. To solve the issue: please run vstest.console.exe from a folder where you have write privileges. For more information, please look at the error message: Access denied while trying to create "TestResults" folder in current location. You are getting this exception because you are running vstest.console.exe from a folder which requires administrator rights. To solve the issue : please open command line "As Administrator" or run vstest.console.exe from a folder where you have admin privileges. diff --git a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.it.xlf b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.it.xlf index 04540b4a6e..2fa712363e 100644 --- a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.it.xlf +++ b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.it.xlf @@ -280,7 +280,7 @@ - {0}. Access denied while trying to create "TestResults" folder in mentioned location. You are getting this exception because you are running vstest.console.exe from a folder which requires having write access. To solve the issue : please run vstest.console.exe from a folder where you have write privileges to that folder. For more information, please look at the error message : + {0} Access denied while trying to create "TestResults" folder in mentioned location. You are getting this exception because you are running vstest.console.exe from a folder which requires having write access. To solve the issue: please run vstest.console.exe from a folder where you have write privileges. For more information, please look at the error message: Access denied while trying to create "TestResults" folder in current location. You are getting this exception because you are running vstest.console.exe from a folder which requires administrator rights. To solve the issue : please open command line "As Administrator" or run vstest.console.exe from a folder where you have admin privileges. diff --git a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.ja.xlf b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.ja.xlf index 9643502cea..2dbbfd1da0 100644 --- a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.ja.xlf +++ b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.ja.xlf @@ -280,7 +280,7 @@ - {0}. Access denied while trying to create "TestResults" folder in mentioned location. You are getting this exception because you are running vstest.console.exe from a folder which requires having write access. To solve the issue : please run vstest.console.exe from a folder where you have write privileges to that folder. For more information, please look at the error message : + {0} Access denied while trying to create "TestResults" folder in mentioned location. You are getting this exception because you are running vstest.console.exe from a folder which requires having write access. To solve the issue: please run vstest.console.exe from a folder where you have write privileges. For more information, please look at the error message: Access denied while trying to create "TestResults" folder in current location. You are getting this exception because you are running vstest.console.exe from a folder which requires administrator rights. To solve the issue : please open command line "As Administrator" or run vstest.console.exe from a folder where you have admin privileges. diff --git a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.ko.xlf b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.ko.xlf index 7bc77f08eb..b4a5aacc1e 100644 --- a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.ko.xlf +++ b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.ko.xlf @@ -280,7 +280,7 @@ - {0}. Access denied while trying to create "TestResults" folder in mentioned location. You are getting this exception because you are running vstest.console.exe from a folder which requires having write access. To solve the issue : please run vstest.console.exe from a folder where you have write privileges to that folder. For more information, please look at the error message : + {0} Access denied while trying to create "TestResults" folder in mentioned location. You are getting this exception because you are running vstest.console.exe from a folder which requires having write access. To solve the issue: please run vstest.console.exe from a folder where you have write privileges. For more information, please look at the error message: Access denied while trying to create "TestResults" folder in current location. You are getting this exception because you are running vstest.console.exe from a folder which requires administrator rights. To solve the issue : please open command line "As Administrator" or run vstest.console.exe from a folder where you have admin privileges. diff --git a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.pl.xlf b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.pl.xlf index fd10033f40..96b31a5915 100644 --- a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.pl.xlf +++ b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.pl.xlf @@ -280,7 +280,7 @@ - {0}. Access denied while trying to create "TestResults" folder in mentioned location. You are getting this exception because you are running vstest.console.exe from a folder which requires having write access. To solve the issue : please run vstest.console.exe from a folder where you have write privileges to that folder. For more information, please look at the error message : + {0} Access denied while trying to create "TestResults" folder in mentioned location. You are getting this exception because you are running vstest.console.exe from a folder which requires having write access. To solve the issue: please run vstest.console.exe from a folder where you have write privileges. For more information, please look at the error message: Access denied while trying to create "TestResults" folder in current location. You are getting this exception because you are running vstest.console.exe from a folder which requires administrator rights. To solve the issue : please open command line "As Administrator" or run vstest.console.exe from a folder where you have admin privileges. diff --git a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.pt-BR.xlf b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.pt-BR.xlf index 4d3159a299..ecea0433f8 100644 --- a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.pt-BR.xlf +++ b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.pt-BR.xlf @@ -280,7 +280,7 @@ - {0}. Access denied while trying to create "TestResults" folder in mentioned location. You are getting this exception because you are running vstest.console.exe from a folder which requires having write access. To solve the issue : please run vstest.console.exe from a folder where you have write privileges to that folder. For more information, please look at the error message : + {0} Access denied while trying to create "TestResults" folder in mentioned location. You are getting this exception because you are running vstest.console.exe from a folder which requires having write access. To solve the issue: please run vstest.console.exe from a folder where you have write privileges. For more information, please look at the error message: Access denied while trying to create "TestResults" folder in current location. You are getting this exception because you are running vstest.console.exe from a folder which requires administrator rights. To solve the issue : please open command line "As Administrator" or run vstest.console.exe from a folder where you have admin privileges. diff --git a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.ru.xlf b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.ru.xlf index 6bf36c92d7..0af790c4d3 100644 --- a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.ru.xlf +++ b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.ru.xlf @@ -280,7 +280,7 @@ - {0}. Access denied while trying to create "TestResults" folder in mentioned location. You are getting this exception because you are running vstest.console.exe from a folder which requires having write access. To solve the issue : please run vstest.console.exe from a folder where you have write privileges to that folder. For more information, please look at the error message : + {0} Access denied while trying to create "TestResults" folder in mentioned location. You are getting this exception because you are running vstest.console.exe from a folder which requires having write access. To solve the issue: please run vstest.console.exe from a folder where you have write privileges. For more information, please look at the error message: Access denied while trying to create "TestResults" folder in current location. You are getting this exception because you are running vstest.console.exe from a folder which requires administrator rights. To solve the issue : please open command line "As Administrator" or run vstest.console.exe from a folder where you have admin privileges. diff --git a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.tr.xlf b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.tr.xlf index 472273c076..8cb4e5a36d 100644 --- a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.tr.xlf +++ b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.tr.xlf @@ -280,7 +280,7 @@ - {0}. Access denied while trying to create "TestResults" folder in mentioned location. You are getting this exception because you are running vstest.console.exe from a folder which requires having write access. To solve the issue : please run vstest.console.exe from a folder where you have write privileges to that folder. For more information, please look at the error message : + {0} Access denied while trying to create "TestResults" folder in mentioned location. You are getting this exception because you are running vstest.console.exe from a folder which requires having write access. To solve the issue: please run vstest.console.exe from a folder where you have write privileges. For more information, please look at the error message: Access denied while trying to create "TestResults" folder in current location. You are getting this exception because you are running vstest.console.exe from a folder which requires administrator rights. To solve the issue : please open command line "As Administrator" or run vstest.console.exe from a folder where you have admin privileges. diff --git a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.xlf b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.xlf index 5221994f6b..257a771cbf 100644 --- a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.xlf +++ b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.xlf @@ -157,7 +157,7 @@ - {0}. Access denied while trying to create "TestResults" folder in mentioned location. You are getting this exception because you are running vstest.console.exe from a folder which requires having write access. To solve the issue : please run vstest.console.exe from a folder where you have write privileges to that folder. For more information, please look at the error message : + {0} Access denied while trying to create "TestResults" folder in mentioned location. You are getting this exception because you are running vstest.console.exe from a folder which requires having write access. To solve the issue: please run vstest.console.exe from a folder where you have write privileges. For more information, please look at the error message: Access denied while trying to create "TestResults" folder in current location. You are getting this exception because you are running vstest.console.exe from a folder which requires administrator rights. To solve the issue : please open command line "As Administrator" or run vstest.console.exe from a folder where you have admin privileges. diff --git a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.zh-Hans.xlf b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.zh-Hans.xlf index 7a75335137..95a2c984e0 100644 --- a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.zh-Hans.xlf +++ b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.zh-Hans.xlf @@ -280,7 +280,7 @@ - {0}. Access denied while trying to create "TestResults" folder in mentioned location. You are getting this exception because you are running vstest.console.exe from a folder which requires having write access. To solve the issue : please run vstest.console.exe from a folder where you have write privileges to that folder. For more information, please look at the error message : + {0} Access denied while trying to create "TestResults" folder in mentioned location. You are getting this exception because you are running vstest.console.exe from a folder which requires having write access. To solve the issue: please run vstest.console.exe from a folder where you have write privileges. For more information, please look at the error message: Access denied while trying to create "TestResults" folder in current location. You are getting this exception because you are running vstest.console.exe from a folder which requires administrator rights. To solve the issue : please open command line "As Administrator" or run vstest.console.exe from a folder where you have admin privileges. diff --git a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.zh-Hant.xlf b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.zh-Hant.xlf index 2fc6733866..237e3d450d 100644 --- a/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.zh-Hant.xlf +++ b/src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.zh-Hant.xlf @@ -280,7 +280,7 @@ - {0}. Access denied while trying to create "TestResults" folder in mentioned location. You are getting this exception because you are running vstest.console.exe from a folder which requires having write access. To solve the issue : please run vstest.console.exe from a folder where you have write privileges to that folder. For more information, please look at the error message : + {0} Access denied while trying to create "TestResults" folder in mentioned location. You are getting this exception because you are running vstest.console.exe from a folder which requires having write access. To solve the issue: please run vstest.console.exe from a folder where you have write privileges. For more information, please look at the error message: Access denied while trying to create "TestResults" folder in current location. You are getting this exception because you are running vstest.console.exe from a folder which requires administrator rights. To solve the issue : please open command line "As Administrator" or run vstest.console.exe from a folder where you have admin privileges. From bf0cacffc7eb525bc5e963592286509524f1e860 Mon Sep 17 00:00:00 2001 From: Sanan Yuzbashiyev Date: Thu, 11 Jun 2020 14:52:35 +0200 Subject: [PATCH 09/14] New exception handling was added --- .../Execution/BaseRunTests.cs | 10 +++++++++- .../Resources/Resources.Designer.cs | 9 +++++++++ .../Resources/Resources.resx | 3 +++ .../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 +++++ 17 files changed, 91 insertions(+), 1 deletion(-) diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Execution/BaseRunTests.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/Execution/BaseRunTests.cs index 7539321f54..ee040ec988 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Execution/BaseRunTests.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Execution/BaseRunTests.cs @@ -458,6 +458,7 @@ private bool RunTestInternalWithExecutors(IEnumerable> execut var exceptionsHitDuringRunTests = false; var executorsFromDeprecatedLocations = false; double totalTimeTakenByAdapters = 0; + foreach (var executorUriExtensionTuple in executorUriExtensionMap) { // Get the executor from the cache. @@ -531,6 +532,13 @@ private bool RunTestInternalWithExecutors(IEnumerable> execut } catch (Exception e) { + string exceptionMessage = ExceptionUtilities.GetExceptionMessage(e); + + if (e is UnauthorizedAccessException) + { + exceptionMessage = string.Format(CultureInfo.CurrentCulture, CrossPlatEngineResources.AccessDenied, e.Message); + } + exceptionsHitDuringRunTests = true; if (EqtTrace.IsErrorEnabled) @@ -547,7 +555,7 @@ private bool RunTestInternalWithExecutors(IEnumerable> execut CultureInfo.CurrentCulture, CrossPlatEngineResources.ExceptionFromRunTests, executorUriExtensionTuple.Item1, - ExceptionUtilities.GetExceptionMessage(e))); + exceptionMessage)); } finally { diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/Resources.Designer.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/Resources.Designer.cs index 76c0fcc402..24d87bbeb9 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/Resources.Designer.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/Resources.Designer.cs @@ -60,6 +60,15 @@ internal Resources() { } } + /// + /// Looks up a localized string similar to {0} Access denied while trying to create "TestResults" folder in mentioned location. You are getting this exception because you are running vstest.console.exe from a folder which requires having write access. To solve the issue: please run vstest.console.exe from a folder where you have write privileges.. + /// + internal static string AccessDenied { + get { + return ResourceManager.GetString("AccessDenied", resourceCulture); + } + } + /// /// Looks up a localized string similar to Cannot attach the debugger to the default test host with process ID: {0}.. /// diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/Resources.resx b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/Resources.resx index 021500345d..4ef18b3697 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/Resources.resx +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/Resources.resx @@ -201,4 +201,7 @@ Cannot attach the debugger to the default test host with process ID: {0}. + + {0} Access denied while trying to create "TestResults" folder in mentioned location. You are getting this exception because you are running vstest.console.exe from a folder which requires having write access. To solve the issue: please run vstest.console.exe from a folder where you have write privileges. + \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.cs.xlf b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.cs.xlf index e6c8dec431..ec4afb05b8 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.cs.xlf +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.cs.xlf @@ -212,6 +212,11 @@ Cannot attach the debugger to the default test host with process ID: {0}. + + {0} Access denied while trying to create "TestResults" folder in mentioned location. You are getting this exception because you are running vstest.console.exe from a folder which requires having write access. To solve the issue: please run vstest.console.exe from a folder where you have write privileges. + {0} Access denied while trying to create "TestResults" folder in mentioned location. You are getting this exception because you are running vstest.console.exe from a folder which requires having write access. To solve the issue: please run vstest.console.exe from a folder where you have write privileges. For more information, please look at the error message: + + \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.de.xlf b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.de.xlf index bf5dbceca2..33bc3a8218 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.de.xlf +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.de.xlf @@ -212,6 +212,11 @@ Cannot attach the debugger to the default test host with process ID: {0}. + + {0} Access denied while trying to create "TestResults" folder in mentioned location. You are getting this exception because you are running vstest.console.exe from a folder which requires having write access. To solve the issue: please run vstest.console.exe from a folder where you have write privileges. + {0} Access denied while trying to create "TestResults" folder in mentioned location. You are getting this exception because you are running vstest.console.exe from a folder which requires having write access. To solve the issue: please run vstest.console.exe from a folder where you have write privileges. For more information, please look at the error message: + + \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.es.xlf b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.es.xlf index ed13906318..58233f7065 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.es.xlf +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.es.xlf @@ -212,6 +212,11 @@ Cannot attach the debugger to the default test host with process ID: {0}. + + {0} Access denied while trying to create "TestResults" folder in mentioned location. You are getting this exception because you are running vstest.console.exe from a folder which requires having write access. To solve the issue: please run vstest.console.exe from a folder where you have write privileges. + {0} Access denied while trying to create "TestResults" folder in mentioned location. You are getting this exception because you are running vstest.console.exe from a folder which requires having write access. To solve the issue: please run vstest.console.exe from a folder where you have write privileges. For more information, please look at the error message: + + \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.fr.xlf b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.fr.xlf index 01b56d16a4..952b38fb2c 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.fr.xlf +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.fr.xlf @@ -212,6 +212,11 @@ Cannot attach the debugger to the default test host with process ID: {0}. + + {0} Access denied while trying to create "TestResults" folder in mentioned location. You are getting this exception because you are running vstest.console.exe from a folder which requires having write access. To solve the issue: please run vstest.console.exe from a folder where you have write privileges. + {0} Access denied while trying to create "TestResults" folder in mentioned location. You are getting this exception because you are running vstest.console.exe from a folder which requires having write access. To solve the issue: please run vstest.console.exe from a folder where you have write privileges. For more information, please look at the error message: + + \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.it.xlf b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.it.xlf index d0e4801854..94c8cde5a0 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.it.xlf +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.it.xlf @@ -212,6 +212,11 @@ Cannot attach the debugger to the default test host with process ID: {0}. + + {0} Access denied while trying to create "TestResults" folder in mentioned location. You are getting this exception because you are running vstest.console.exe from a folder which requires having write access. To solve the issue: please run vstest.console.exe from a folder where you have write privileges. + {0} Access denied while trying to create "TestResults" folder in mentioned location. You are getting this exception because you are running vstest.console.exe from a folder which requires having write access. To solve the issue: please run vstest.console.exe from a folder where you have write privileges. For more information, please look at the error message: + + \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.ja.xlf b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.ja.xlf index e036370c89..353c1a944d 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.ja.xlf +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.ja.xlf @@ -212,6 +212,11 @@ Cannot attach the debugger to the default test host with process ID: {0}. + + {0} Access denied while trying to create "TestResults" folder in mentioned location. You are getting this exception because you are running vstest.console.exe from a folder which requires having write access. To solve the issue: please run vstest.console.exe from a folder where you have write privileges. + {0} Access denied while trying to create "TestResults" folder in mentioned location. You are getting this exception because you are running vstest.console.exe from a folder which requires having write access. To solve the issue: please run vstest.console.exe from a folder where you have write privileges. For more information, please look at the error message: + + \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.ko.xlf b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.ko.xlf index 138614b854..b8b5c22af3 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.ko.xlf +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.ko.xlf @@ -212,6 +212,11 @@ Cannot attach the debugger to the default test host with process ID: {0}. + + {0} Access denied while trying to create "TestResults" folder in mentioned location. You are getting this exception because you are running vstest.console.exe from a folder which requires having write access. To solve the issue: please run vstest.console.exe from a folder where you have write privileges. + {0} Access denied while trying to create "TestResults" folder in mentioned location. You are getting this exception because you are running vstest.console.exe from a folder which requires having write access. To solve the issue: please run vstest.console.exe from a folder where you have write privileges. For more information, please look at the error message: + + \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.pl.xlf b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.pl.xlf index 749f3cc4a5..06e4e59824 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.pl.xlf +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.pl.xlf @@ -212,6 +212,11 @@ Cannot attach the debugger to the default test host with process ID: {0}. + + {0} Access denied while trying to create "TestResults" folder in mentioned location. You are getting this exception because you are running vstest.console.exe from a folder which requires having write access. To solve the issue: please run vstest.console.exe from a folder where you have write privileges. + {0} Access denied while trying to create "TestResults" folder in mentioned location. You are getting this exception because you are running vstest.console.exe from a folder which requires having write access. To solve the issue: please run vstest.console.exe from a folder where you have write privileges. For more information, please look at the error message: + + \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.pt-BR.xlf b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.pt-BR.xlf index 44da41742a..bcf84ab86e 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.pt-BR.xlf +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.pt-BR.xlf @@ -212,6 +212,11 @@ Cannot attach the debugger to the default test host with process ID: {0}. + + {0} Access denied while trying to create "TestResults" folder in mentioned location. You are getting this exception because you are running vstest.console.exe from a folder which requires having write access. To solve the issue: please run vstest.console.exe from a folder where you have write privileges. + {0} Access denied while trying to create "TestResults" folder in mentioned location. You are getting this exception because you are running vstest.console.exe from a folder which requires having write access. To solve the issue: please run vstest.console.exe from a folder where you have write privileges. For more information, please look at the error message: + + \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.ru.xlf b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.ru.xlf index 0ebcb9e5dd..4c58d7ff4d 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.ru.xlf +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.ru.xlf @@ -212,6 +212,11 @@ Cannot attach the debugger to the default test host with process ID: {0}. + + {0} Access denied while trying to create "TestResults" folder in mentioned location. You are getting this exception because you are running vstest.console.exe from a folder which requires having write access. To solve the issue: please run vstest.console.exe from a folder where you have write privileges. + {0} Access denied while trying to create "TestResults" folder in mentioned location. You are getting this exception because you are running vstest.console.exe from a folder which requires having write access. To solve the issue: please run vstest.console.exe from a folder where you have write privileges. For more information, please look at the error message: + + \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.tr.xlf b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.tr.xlf index 924a516fb4..624de39802 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.tr.xlf +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.tr.xlf @@ -212,6 +212,11 @@ Cannot attach the debugger to the default test host with process ID: {0}. + + {0} Access denied while trying to create "TestResults" folder in mentioned location. You are getting this exception because you are running vstest.console.exe from a folder which requires having write access. To solve the issue: please run vstest.console.exe from a folder where you have write privileges. + {0} Access denied while trying to create "TestResults" folder in mentioned location. You are getting this exception because you are running vstest.console.exe from a folder which requires having write access. To solve the issue: please run vstest.console.exe from a folder where you have write privileges. For more information, please look at the error message: + + \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.xlf b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.xlf index 453f023f7f..7c88354463 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.xlf +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.xlf @@ -123,6 +123,11 @@ Cannot attach the debugger to the default test host with process ID: {0}. + + {0} Access denied while trying to create "TestResults" folder in mentioned location. You are getting this exception because you are running vstest.console.exe from a folder which requires having write access. To solve the issue: please run vstest.console.exe from a folder where you have write privileges. + {0} Access denied while trying to create "TestResults" folder in mentioned location. You are getting this exception because you are running vstest.console.exe from a folder which requires having write access. To solve the issue: please run vstest.console.exe from a folder where you have write privileges. For more information, please look at the error message: + + \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.zh-Hans.xlf b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.zh-Hans.xlf index e544a4d368..31360a28ee 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.zh-Hans.xlf +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.zh-Hans.xlf @@ -212,6 +212,11 @@ Cannot attach the debugger to the default test host with process ID: {0}. + + {0} Access denied while trying to create "TestResults" folder in mentioned location. You are getting this exception because you are running vstest.console.exe from a folder which requires having write access. To solve the issue: please run vstest.console.exe from a folder where you have write privileges. + {0} Access denied while trying to create "TestResults" folder in mentioned location. You are getting this exception because you are running vstest.console.exe from a folder which requires having write access. To solve the issue: please run vstest.console.exe from a folder where you have write privileges. For more information, please look at the error message: + + \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.zh-Hant.xlf b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.zh-Hant.xlf index 88ef56f6b7..9dcff5d197 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.zh-Hant.xlf +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.zh-Hant.xlf @@ -212,6 +212,11 @@ Cannot attach the debugger to the default test host with process ID: {0}. + + {0} Access denied while trying to create "TestResults" folder in mentioned location. You are getting this exception because you are running vstest.console.exe from a folder which requires having write access. To solve the issue: please run vstest.console.exe from a folder where you have write privileges. + {0} Access denied while trying to create "TestResults" folder in mentioned location. You are getting this exception because you are running vstest.console.exe from a folder which requires having write access. To solve the issue: please run vstest.console.exe from a folder where you have write privileges. For more information, please look at the error message: + + \ No newline at end of file From 2582e75ac68bae6bc46f22d5e8b9f78ff31e4f84 Mon Sep 17 00:00:00 2001 From: Sanan Yuzbashiyev Date: Thu, 11 Jun 2020 22:54:02 +0200 Subject: [PATCH 10/14] Formatted exception message --- .../Execution/BaseRunTests.cs | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Execution/BaseRunTests.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/Execution/BaseRunTests.cs index ee040ec988..15a0295aa4 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Execution/BaseRunTests.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Execution/BaseRunTests.cs @@ -531,14 +531,11 @@ private bool RunTestInternalWithExecutors(IEnumerable> execut totalTimeTakenByAdapters += totalTimeTaken.TotalSeconds; } catch (Exception e) - { - string exceptionMessage = ExceptionUtilities.GetExceptionMessage(e); - - if (e is UnauthorizedAccessException) - { - exceptionMessage = string.Format(CultureInfo.CurrentCulture, CrossPlatEngineResources.AccessDenied, e.Message); - } - + { + string exceptionMessage = (e is UnauthorizedAccessException) + ? string.Format(CultureInfo.CurrentCulture, CrossPlatEngineResources.AccessDenied, e.Message) + : ExceptionUtilities.GetExceptionMessage(e); + exceptionsHitDuringRunTests = true; if (EqtTrace.IsErrorEnabled) From a97cdd15bc4c442a55d1930ddf79e71b647a44a0 Mon Sep 17 00:00:00 2001 From: Sanan Yuzbashiyev Date: Thu, 29 Oct 2020 17:52:24 +0100 Subject: [PATCH 11/14] Initial implementaion --- .../Utilities/RunSettingsUtilities.cs | 40 +++++++++++++++++++ .../RunSettings/RunConfiguration.cs | 37 ++++++++++++++++- .../RunSpecificTestsArgumentProcessor.cs | 16 ++++++-- .../Processors/RunTestsArgumentProcessor.cs | 25 +++++++++--- src/vstest.console/Program.cs | 15 ++++--- 5 files changed, 117 insertions(+), 16 deletions(-) diff --git a/src/Microsoft.TestPlatform.Common/Utilities/RunSettingsUtilities.cs b/src/Microsoft.TestPlatform.Common/Utilities/RunSettingsUtilities.cs index caee639e54..56c5b3a62a 100644 --- a/src/Microsoft.TestPlatform.Common/Utilities/RunSettingsUtilities.cs +++ b/src/Microsoft.TestPlatform.Common/Utilities/RunSettingsUtilities.cs @@ -130,6 +130,46 @@ public static int GetMaxCpuCount(RunConfiguration runConfiguration) return cpuCount; } + /// + /// Gets the value of FailWhenNoTestsFound parameter from runsettings file + /// + /// Runsetting string value + /// The value of FailWhenNoTestsFound + public static bool GetFailWhenNoTestsFound(string runSettings) + { + bool failWhenNoTestFound = false; + + if (runSettings != null) + { + try + { + RunConfiguration runConfiguration = XmlRunSettingsUtilities.GetRunConfigurationNode(runSettings); + failWhenNoTestFound = GetFailWhenNoTestsFound(runConfiguration); + } + catch (SettingsException se) + { + if (EqtTrace.IsErrorEnabled) + { + EqtTrace.Error("RunSpecificTestsArgumentProcessor.GetFailWhenNoTestsFound: Unable to get the value of FailWhenNoTestsFound from runsettings: Error {0}", se); + } + } + } + + return failWhenNoTestFound; + } + + private static bool GetFailWhenNoTestsFound(RunConfiguration runConfiguration) + { + bool failWhenNoTestsFound = false; + + if (runConfiguration != null) + { + failWhenNoTestsFound = runConfiguration.FailWhenNoTestsFound; + } + + return failWhenNoTestsFound; + } + /// /// Gets the test adapters path from the run configuration diff --git a/src/Microsoft.TestPlatform.ObjectModel/RunSettings/RunConfiguration.cs b/src/Microsoft.TestPlatform.ObjectModel/RunSettings/RunConfiguration.cs index 8b1476124a..7c76c093f7 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/RunSettings/RunConfiguration.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/RunSettings/RunConfiguration.cs @@ -84,6 +84,11 @@ public class RunConfiguration : TestRunSettings /// private string targetDevice; + /// + /// Defines if Test Platform should return non-zero value if no tests found and executed + /// + private bool failWhenNoTestsFound; + #endregion #region Constructor @@ -308,6 +313,18 @@ public Framework TargetFramework } } + public bool FailWhenNoTestsFound + { + get + { + return failWhenNoTestsFound; + } + set + { + this.failWhenNoTestsFound = value; + } + } + /// /// Gets or sets the target Framework this run is targeting. Possible values are Framework3.5|Framework4.0|Framework4.5 /// @@ -594,6 +611,13 @@ public override XmlElement ToXml() root.AppendChild(dotnetHostPath); } + if (this.FailWhenNoTestsFound) + { + XmlElement treatAsError = doc.CreateElement(nameof(FailWhenNoTestsFound)); + treatAsError.InnerText = this.FailWhenNoTestsFound.ToString(); + root.AppendChild(treatAsError); + } + return root; } @@ -754,7 +778,7 @@ public static RunConfiguration FromXml(XmlReader reader) bool disableParallelizationCheck; if (!bool.TryParse(disableParallelizationValueString, out disableParallelizationCheck)) { - throw new SettingsException(String.Format(CultureInfo.CurrentCulture, + throw new SettingsException(string.Format(CultureInfo.CurrentCulture, Resources.Resources.InvalidSettingsIncorrectValue, Constants.RunConfigurationSettingsName, disableParallelizationValueString, elementName)); } runConfiguration.DisableParallelization = disableParallelizationCheck; @@ -899,6 +923,17 @@ public static RunConfiguration FromXml(XmlReader reader) XmlRunSettingsUtilities.ThrowOnHasAttributes(reader); runConfiguration.DotnetHostPath = reader.ReadElementContentAsString(); break; + case "FailWhenNoTestsFound": + XmlRunSettingsUtilities.ThrowOnHasAttributes(reader); + string failWhenNoTestsFoundValueString = reader.ReadElementContentAsString(); + bool failWhenNoTestsFound; + if (!bool.TryParse(failWhenNoTestsFoundValueString, out failWhenNoTestsFound)) + { + throw new SettingsException(string.Format(CultureInfo.CurrentCulture, + Resources.Resources.InvalidSettingsIncorrectValue, Constants.RunConfigurationSettingsName, failWhenNoTestsFoundValueString, elementName)); + } + runConfiguration.FailWhenNoTestsFound = failWhenNoTestsFound; + break; default: // Ignore a runsettings element that we don't understand. It could occur in the case diff --git a/src/vstest.console/Processors/RunSpecificTestsArgumentProcessor.cs b/src/vstest.console/Processors/RunSpecificTestsArgumentProcessor.cs index a8a30a1747..4e25f55bfb 100644 --- a/src/vstest.console/Processors/RunSpecificTestsArgumentProcessor.cs +++ b/src/vstest.console/Processors/RunSpecificTestsArgumentProcessor.cs @@ -10,15 +10,16 @@ namespace Microsoft.VisualStudio.TestPlatform.CommandLine.Processors using System.Globalization; using System.Linq; + using Microsoft.VisualStudio.TestPlatform.Common; + using Microsoft.VisualStudio.TestPlatform.Common.Interfaces; + using Microsoft.VisualStudio.TestPlatform.Common.Utilities; using Microsoft.VisualStudio.TestPlatform.Client.RequestHelper; using Microsoft.VisualStudio.TestPlatform.CommandLine.Internal; using Microsoft.VisualStudio.TestPlatform.CommandLine.TestPlatformHelpers; - using Microsoft.VisualStudio.TestPlatform.Common; - using Microsoft.VisualStudio.TestPlatform.Common.Interfaces; using Microsoft.VisualStudio.TestPlatform.ObjectModel; using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; using Microsoft.VisualStudio.TestPlatform.Utilities; - using CommandLineResources = Microsoft.VisualStudio.TestPlatform.CommandLine.Resources.Resources; + using CommandLineResources = Resources.Resources; internal class RunSpecificTestsArgumentProcessor : IArgumentProcessor { @@ -218,6 +219,14 @@ public ArgumentProcessorResult Execute() // Now that tests are discovered and filtered, we run only those selected tests. this.ExecuteSelectedTests(); + bool failWhenNoTestsFound = RunSettingsUtilities.GetFailWhenNoTestsFound(effectiveRunSettings); + + // If no tests found and FailWhenNoTestsFound parameter set to `true` then return fail + if (failWhenNoTestsFound && this.selectedTestCases.Count == 0) + { + return ArgumentProcessorResult.Fail; + } + return ArgumentProcessorResult.Success; } @@ -285,6 +294,7 @@ private void ExecuteSelectedTests() } } + /// /// Filter discovered tests and find matching tests from given search strings. /// Any name of the test that can match multiple strings will be added only once. diff --git a/src/vstest.console/Processors/RunTestsArgumentProcessor.cs b/src/vstest.console/Processors/RunTestsArgumentProcessor.cs index 48c962106f..36ec9c0dd3 100644 --- a/src/vstest.console/Processors/RunTestsArgumentProcessor.cs +++ b/src/vstest.console/Processors/RunTestsArgumentProcessor.cs @@ -4,7 +4,6 @@ namespace Microsoft.VisualStudio.TestPlatform.CommandLine.Processors { using System; - using System.Collections.Generic; using System.Diagnostics.Contracts; using System.Globalization; using System.Linq; @@ -14,11 +13,12 @@ namespace Microsoft.VisualStudio.TestPlatform.CommandLine.Processors using Microsoft.VisualStudio.TestPlatform.CommandLine.TestPlatformHelpers; using Microsoft.VisualStudio.TestPlatform.Common; using Microsoft.VisualStudio.TestPlatform.Common.Interfaces; + using Microsoft.VisualStudio.TestPlatform.Common.Utilities; using Microsoft.VisualStudio.TestPlatform.ObjectModel; using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; using Microsoft.VisualStudio.TestPlatform.Utilities; - using CommandLineResources = Microsoft.VisualStudio.TestPlatform.CommandLine.Resources.Resources; + using CommandLineResources = Resources.Resources; internal class RunTestsArgumentProcessor : IArgumentProcessor { @@ -110,6 +110,11 @@ internal class RunTestsArgumentExecutor : IArgumentExecutor /// Registers and Unregisters for test run events before and after test run /// private ITestRunEventsRegistrar testRunEventsRegistrar; + + /// + /// Shows the number of tests which were executed + /// + private static long numberOfExecutedTests; #endregion @@ -168,15 +173,24 @@ public ArgumentProcessorResult Execute() this.output.Information(false, CommandLineResources.VstestDiagLogOutputPath, EqtTrace.LogFile); } + var runSettings = this.runSettingsManager.ActiveRunSettings.SettingsXml; + if (this.commandLineOptions.Sources.Any()) { - this.RunTests(this.commandLineOptions.Sources); + this.RunTests(runSettings); + } + + bool failWhenNoTestsFound = RunSettingsUtilities.GetFailWhenNoTestsFound(runSettings); + + if (failWhenNoTestsFound && numberOfExecutedTests == 0) + { + return ArgumentProcessorResult.Fail; } return ArgumentProcessorResult.Success; } - private void RunTests(IEnumerable sources) + private void RunTests(string runSettings) { // create/start test run if (EqtTrace.IsInfoEnabled) @@ -184,8 +198,6 @@ private void RunTests(IEnumerable sources) EqtTrace.Info("RunTestsArgumentProcessor:Execute: Test run is starting."); } - var runSettings = this.runSettingsManager.ActiveRunSettings.SettingsXml; - if (EqtTrace.IsVerboseEnabled) { EqtTrace.Verbose("RunTestsArgumentProcessor:Execute: Queuing Test run."); @@ -241,6 +253,7 @@ private void TestRunRequest_OnRunCompletion(object sender, TestRunCompleteEventA // we need to check if there are any tests executed - to try show some help info to user to check for installed vsix extensions if (!e.IsAborted && !e.IsCanceled) { + numberOfExecutedTests = e.TestRunStatistics.ExecutedTests; var testsFoundInAnySource = (e.TestRunStatistics == null) ? false : (e.TestRunStatistics.ExecutedTests > 0); // Indicate the user to use test adapter path command if there are no tests found diff --git a/src/vstest.console/Program.cs b/src/vstest.console/Program.cs index 484f9f9a7a..d04604efcc 100644 --- a/src/vstest.console/Program.cs +++ b/src/vstest.console/Program.cs @@ -4,7 +4,9 @@ namespace Microsoft.VisualStudio.TestPlatform.CommandLine { using System; + using System.Diagnostics; using System.Globalization; + using System.Threading; using Microsoft.VisualStudio.TestPlatform.Utilities; /// @@ -24,22 +26,23 @@ public static int Main(string[] args) { ConsoleOutput.Instance.WriteLine("Waiting for debugger attach...", OutputLevel.Information); - var currentProcess = System.Diagnostics.Process.GetCurrentProcess(); + var currentProcess = Process.GetCurrentProcess(); ConsoleOutput.Instance.WriteLine( string.Format("Process Id: {0}, Name: {1}", currentProcess.Id, currentProcess.ProcessName), OutputLevel.Information); - while (!System.Diagnostics.Debugger.IsAttached) + while (!Debugger.IsAttached) { - System.Threading.Thread.Sleep(1000); + Thread.Sleep(1000); } - System.Diagnostics.Debugger.Break(); + Debugger.Break(); } SetCultureSpecifiedByUser(); - - return new Executor(ConsoleOutput.Instance).Execute(args); + int exitCode = new Executor(ConsoleOutput.Instance).Execute(args); + ConsoleOutput.Instance.WriteLine(string.Format("ExitCode {0}", exitCode), OutputLevel.Information); + return exitCode; } private static void SetCultureSpecifiedByUser() From d55e7ea5462597c5f1412eec8624ad959151d115 Mon Sep 17 00:00:00 2001 From: Sanan Yuzbashiyev Date: Fri, 30 Oct 2020 17:30:39 +0100 Subject: [PATCH 12/14] Added acceptance tests. Removed unnecessary console output --- .../Processors/RunTestsArgumentProcessor.cs | 1 + src/vstest.console/Program.cs | 4 +- .../ExecutionTests.cs | 74 +++++++++++++++++++ 3 files changed, 76 insertions(+), 3 deletions(-) diff --git a/src/vstest.console/Processors/RunTestsArgumentProcessor.cs b/src/vstest.console/Processors/RunTestsArgumentProcessor.cs index 36ec9c0dd3..cd0e8ff01e 100644 --- a/src/vstest.console/Processors/RunTestsArgumentProcessor.cs +++ b/src/vstest.console/Processors/RunTestsArgumentProcessor.cs @@ -182,6 +182,7 @@ public ArgumentProcessorResult Execute() bool failWhenNoTestsFound = RunSettingsUtilities.GetFailWhenNoTestsFound(runSettings); + // If no tests found and FailWhenNoTestsFound parameter set to `true` then return fail if (failWhenNoTestsFound && numberOfExecutedTests == 0) { return ArgumentProcessorResult.Fail; diff --git a/src/vstest.console/Program.cs b/src/vstest.console/Program.cs index d04604efcc..3a6ea7c0c1 100644 --- a/src/vstest.console/Program.cs +++ b/src/vstest.console/Program.cs @@ -40,9 +40,7 @@ public static int Main(string[] args) } SetCultureSpecifiedByUser(); - int exitCode = new Executor(ConsoleOutput.Instance).Execute(args); - ConsoleOutput.Instance.WriteLine(string.Format("ExitCode {0}", exitCode), OutputLevel.Information); - return exitCode; + return new Executor(ConsoleOutput.Instance).Execute(args); } private static void SetCultureSpecifiedByUser() diff --git a/test/Microsoft.TestPlatform.AcceptanceTests/ExecutionTests.cs b/test/Microsoft.TestPlatform.AcceptanceTests/ExecutionTests.cs index 88d2c498c3..45cebeb1b1 100644 --- a/test/Microsoft.TestPlatform.AcceptanceTests/ExecutionTests.cs +++ b/test/Microsoft.TestPlatform.AcceptanceTests/ExecutionTests.cs @@ -263,5 +263,79 @@ public void IncompatibleSourcesWarningShouldBeDisplayedInTheConsoleOnlyWhenRunni this.StdOutputContains(expectedWarningContains); } } + + [TestMethod] + [NetFullTargetFrameworkDataSource] + public void ExitCodeShouldReturnOneWhenFailWhenNoTestsFoundParameterSetToTrueAndNoTestAvailableWithFilter(RunnerInfo runnerInfo) + { + SetTestEnvironment(this.testEnvironment, runnerInfo); + + var assemblyPaths = this.BuildMultipleAssemblyPath("SimpleTestProject2.dll").Trim('\"'); + + var arguments = PrepareArguments(assemblyPaths, this.GetTestAdapterPath(), string.Empty, this.FrameworkArgValue, runnerInfo.InIsolationValue); + + // Setting /TestCaseFilter to random test name, which does not exists + arguments = string.Concat(arguments, " /TestCaseFilter:SomeRandomTestName"); + + // set FailWhenNoTestsFound to true + arguments = string.Concat(arguments, " -- RunConfiguration.FailWhenNoTestsFound=true"); + this.InvokeVsTest(arguments); + + this.ExitCodeEquals(1); + } + + [TestMethod] + [NetFullTargetFrameworkDataSource] + public void ExitCodeShouldReturnZeroWhenFailWhenNoTestsFoundParameterSetToTrueAndNoTestAvailableWithFilter(RunnerInfo runnerInfo) + { + SetTestEnvironment(this.testEnvironment, runnerInfo); + + var assemblyPaths = this.BuildMultipleAssemblyPath("SimpleTestProject2.dll").Trim('\"'); + + var arguments = PrepareArguments(assemblyPaths, this.GetTestAdapterPath(), string.Empty, this.FrameworkArgValue, runnerInfo.InIsolationValue); + + // Setting /TestCaseFilter to random test name, which does not exists + arguments = string.Concat(arguments, " /TestCaseFilter:SomeRandomTestName"); + + // set FailWhenNoTestsFound to true + arguments = string.Concat(arguments, " -- RunConfiguration.FailWhenNoTestsFound=false"); + this.InvokeVsTest(arguments); + + this.ExitCodeEquals(0); + } + + [TestMethod] + [NetFullTargetFrameworkDataSource] + public void ExitCodeShouldNotDependOnFailWhenNoTestsFoundTrueValueWhenTestsAreAvailable(RunnerInfo runnerInfo) + { + SetTestEnvironment(this.testEnvironment, runnerInfo); + + var assemblyPaths = this.BuildMultipleAssemblyPath("SimpleTestProject2.dll").Trim('\"'); + + var arguments = PrepareArguments(assemblyPaths, this.GetTestAdapterPath(), string.Empty, this.FrameworkArgValue, runnerInfo.InIsolationValue); + + // set FailWhenNoTestsFound to true + arguments = string.Concat(arguments, " -- RunConfiguration.FailWhenNoTestsFound=true"); + this.InvokeVsTest(arguments); + + this.ExitCodeEquals(1); + } + + [TestMethod] + [NetFullTargetFrameworkDataSource] + public void ExitCodeShouldNotDependOnFailWhenNoTestsFoundFalseValueWhenTestsAreAvailable(RunnerInfo runnerInfo) + { + SetTestEnvironment(this.testEnvironment, runnerInfo); + + var assemblyPaths = this.BuildMultipleAssemblyPath("SimpleTestProject2.dll").Trim('\"'); + + var arguments = PrepareArguments(assemblyPaths, this.GetTestAdapterPath(), string.Empty, this.FrameworkArgValue, runnerInfo.InIsolationValue); + + // set FailWhenNoTestsFound to true + arguments = string.Concat(arguments, " -- RunConfiguration.FailWhenNoTestsFound=true"); + this.InvokeVsTest(arguments); + + this.ExitCodeEquals(1); + } } } From d0f3773c90d6d9116e5b3ad68711230e08c7c21c Mon Sep 17 00:00:00 2001 From: Sanan Yuzbashiyev Date: Mon, 2 Nov 2020 19:53:46 +0100 Subject: [PATCH 13/14] Review changes --- .../Utilities/RunSettingsUtilities.cs | 14 +++---- .../RunSettings/RunConfiguration.cs | 41 ++++++++----------- .../RunSpecificTestsArgumentProcessor.cs | 5 +-- .../Processors/RunTestsArgumentProcessor.cs | 5 +-- src/vstest.console/Program.cs | 11 +++-- .../ExecutionTests.cs | 32 +++++++-------- 6 files changed, 47 insertions(+), 61 deletions(-) diff --git a/src/Microsoft.TestPlatform.Common/Utilities/RunSettingsUtilities.cs b/src/Microsoft.TestPlatform.Common/Utilities/RunSettingsUtilities.cs index 56c5b3a62a..e9b655bd1c 100644 --- a/src/Microsoft.TestPlatform.Common/Utilities/RunSettingsUtilities.cs +++ b/src/Microsoft.TestPlatform.Common/Utilities/RunSettingsUtilities.cs @@ -135,7 +135,7 @@ public static int GetMaxCpuCount(RunConfiguration runConfiguration) /// /// Runsetting string value /// The value of FailWhenNoTestsFound - public static bool GetFailWhenNoTestsFound(string runSettings) + public static bool GetTreatNoTestsAsError(string runSettings) { bool failWhenNoTestFound = false; @@ -144,13 +144,13 @@ public static bool GetFailWhenNoTestsFound(string runSettings) try { RunConfiguration runConfiguration = XmlRunSettingsUtilities.GetRunConfigurationNode(runSettings); - failWhenNoTestFound = GetFailWhenNoTestsFound(runConfiguration); + failWhenNoTestFound = GetTreatNoTestsAsError(runConfiguration); } catch (SettingsException se) { if (EqtTrace.IsErrorEnabled) { - EqtTrace.Error("RunSpecificTestsArgumentProcessor.GetFailWhenNoTestsFound: Unable to get the value of FailWhenNoTestsFound from runsettings: Error {0}", se); + EqtTrace.Error("RunSettingsUtilities.GetTreatNoTestsAsError: Unable to get the value of TreatNoTestsAsError from runsettings: Error {0}", se); } } } @@ -158,16 +158,16 @@ public static bool GetFailWhenNoTestsFound(string runSettings) return failWhenNoTestFound; } - private static bool GetFailWhenNoTestsFound(RunConfiguration runConfiguration) + private static bool GetTreatNoTestsAsError(RunConfiguration runConfiguration) { - bool failWhenNoTestsFound = false; + bool treatNoTestsAsError = false; if (runConfiguration != null) { - failWhenNoTestsFound = runConfiguration.FailWhenNoTestsFound; + treatNoTestsAsError = runConfiguration.TreatNoTestsAsError; } - return failWhenNoTestsFound; + return treatNoTestsAsError; } diff --git a/src/Microsoft.TestPlatform.ObjectModel/RunSettings/RunConfiguration.cs b/src/Microsoft.TestPlatform.ObjectModel/RunSettings/RunConfiguration.cs index 7c76c093f7..e4488dcea7 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/RunSettings/RunConfiguration.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/RunSettings/RunConfiguration.cs @@ -84,11 +84,6 @@ public class RunConfiguration : TestRunSettings /// private string targetDevice; - /// - /// Defines if Test Platform should return non-zero value if no tests found and executed - /// - private bool failWhenNoTestsFound; - #endregion #region Constructor @@ -312,17 +307,13 @@ public Framework TargetFramework this.TargetFrameworkSet = true; } } - - public bool FailWhenNoTestsFound - { - get - { - return failWhenNoTestsFound; - } - set - { - this.failWhenNoTestsFound = value; - } + /// + /// Gets or sets value indicating exit code when no tests are discovered or executed + /// + public bool TreatNoTestsAsError + { + get; + set; } /// @@ -611,10 +602,10 @@ public override XmlElement ToXml() root.AppendChild(dotnetHostPath); } - if (this.FailWhenNoTestsFound) + if (this.TreatNoTestsAsError) { - XmlElement treatAsError = doc.CreateElement(nameof(FailWhenNoTestsFound)); - treatAsError.InnerText = this.FailWhenNoTestsFound.ToString(); + XmlElement treatAsError = doc.CreateElement(nameof(TreatNoTestsAsError)); + treatAsError.InnerText = this.TreatNoTestsAsError.ToString(); root.AppendChild(treatAsError); } @@ -923,16 +914,16 @@ public static RunConfiguration FromXml(XmlReader reader) XmlRunSettingsUtilities.ThrowOnHasAttributes(reader); runConfiguration.DotnetHostPath = reader.ReadElementContentAsString(); break; - case "FailWhenNoTestsFound": + case "TreatNoTestsAsError": XmlRunSettingsUtilities.ThrowOnHasAttributes(reader); - string failWhenNoTestsFoundValueString = reader.ReadElementContentAsString(); - bool failWhenNoTestsFound; - if (!bool.TryParse(failWhenNoTestsFoundValueString, out failWhenNoTestsFound)) + string treatNoTestsAsErrorValueString = reader.ReadElementContentAsString(); + bool treatNoTestsAsError; + if (!bool.TryParse(treatNoTestsAsErrorValueString, out treatNoTestsAsError)) { throw new SettingsException(string.Format(CultureInfo.CurrentCulture, - Resources.Resources.InvalidSettingsIncorrectValue, Constants.RunConfigurationSettingsName, failWhenNoTestsFoundValueString, elementName)); + Resources.Resources.InvalidSettingsIncorrectValue, Constants.RunConfigurationSettingsName, treatNoTestsAsErrorValueString, elementName)); } - runConfiguration.FailWhenNoTestsFound = failWhenNoTestsFound; + runConfiguration.TreatNoTestsAsError = treatNoTestsAsError; break; default: diff --git a/src/vstest.console/Processors/RunSpecificTestsArgumentProcessor.cs b/src/vstest.console/Processors/RunSpecificTestsArgumentProcessor.cs index 4e25f55bfb..2ec28a3825 100644 --- a/src/vstest.console/Processors/RunSpecificTestsArgumentProcessor.cs +++ b/src/vstest.console/Processors/RunSpecificTestsArgumentProcessor.cs @@ -219,10 +219,9 @@ public ArgumentProcessorResult Execute() // Now that tests are discovered and filtered, we run only those selected tests. this.ExecuteSelectedTests(); - bool failWhenNoTestsFound = RunSettingsUtilities.GetFailWhenNoTestsFound(effectiveRunSettings); + bool treatNoTestsAsError = RunSettingsUtilities.GetTreatNoTestsAsError(effectiveRunSettings); - // If no tests found and FailWhenNoTestsFound parameter set to `true` then return fail - if (failWhenNoTestsFound && this.selectedTestCases.Count == 0) + if (treatNoTestsAsError && this.selectedTestCases.Count == 0) { return ArgumentProcessorResult.Fail; } diff --git a/src/vstest.console/Processors/RunTestsArgumentProcessor.cs b/src/vstest.console/Processors/RunTestsArgumentProcessor.cs index cd0e8ff01e..4e624019f2 100644 --- a/src/vstest.console/Processors/RunTestsArgumentProcessor.cs +++ b/src/vstest.console/Processors/RunTestsArgumentProcessor.cs @@ -180,10 +180,9 @@ public ArgumentProcessorResult Execute() this.RunTests(runSettings); } - bool failWhenNoTestsFound = RunSettingsUtilities.GetFailWhenNoTestsFound(runSettings); + bool treatNoTestsAsError = RunSettingsUtilities.GetTreatNoTestsAsError(runSettings); - // If no tests found and FailWhenNoTestsFound parameter set to `true` then return fail - if (failWhenNoTestsFound && numberOfExecutedTests == 0) + if (treatNoTestsAsError && numberOfExecutedTests == 0) { return ArgumentProcessorResult.Fail; } diff --git a/src/vstest.console/Program.cs b/src/vstest.console/Program.cs index 3a6ea7c0c1..484f9f9a7a 100644 --- a/src/vstest.console/Program.cs +++ b/src/vstest.console/Program.cs @@ -4,9 +4,7 @@ namespace Microsoft.VisualStudio.TestPlatform.CommandLine { using System; - using System.Diagnostics; using System.Globalization; - using System.Threading; using Microsoft.VisualStudio.TestPlatform.Utilities; /// @@ -26,20 +24,21 @@ public static int Main(string[] args) { ConsoleOutput.Instance.WriteLine("Waiting for debugger attach...", OutputLevel.Information); - var currentProcess = Process.GetCurrentProcess(); + var currentProcess = System.Diagnostics.Process.GetCurrentProcess(); ConsoleOutput.Instance.WriteLine( string.Format("Process Id: {0}, Name: {1}", currentProcess.Id, currentProcess.ProcessName), OutputLevel.Information); - while (!Debugger.IsAttached) + while (!System.Diagnostics.Debugger.IsAttached) { - Thread.Sleep(1000); + System.Threading.Thread.Sleep(1000); } - Debugger.Break(); + System.Diagnostics.Debugger.Break(); } SetCultureSpecifiedByUser(); + return new Executor(ConsoleOutput.Instance).Execute(args); } diff --git a/test/Microsoft.TestPlatform.AcceptanceTests/ExecutionTests.cs b/test/Microsoft.TestPlatform.AcceptanceTests/ExecutionTests.cs index 45cebeb1b1..8f356095e4 100644 --- a/test/Microsoft.TestPlatform.AcceptanceTests/ExecutionTests.cs +++ b/test/Microsoft.TestPlatform.AcceptanceTests/ExecutionTests.cs @@ -266,7 +266,7 @@ public void IncompatibleSourcesWarningShouldBeDisplayedInTheConsoleOnlyWhenRunni [TestMethod] [NetFullTargetFrameworkDataSource] - public void ExitCodeShouldReturnOneWhenFailWhenNoTestsFoundParameterSetToTrueAndNoTestAvailableWithFilter(RunnerInfo runnerInfo) + public void ExitCodeShouldReturnOneWhenTreatNoTestsAsErrorParameterSetToTrueAndNoTestMatchesFilter(RunnerInfo runnerInfo) { SetTestEnvironment(this.testEnvironment, runnerInfo); @@ -274,11 +274,10 @@ public void ExitCodeShouldReturnOneWhenFailWhenNoTestsFoundParameterSetToTrueAnd var arguments = PrepareArguments(assemblyPaths, this.GetTestAdapterPath(), string.Empty, this.FrameworkArgValue, runnerInfo.InIsolationValue); - // Setting /TestCaseFilter to random test name, which does not exists - arguments = string.Concat(arguments, " /TestCaseFilter:SomeRandomTestName"); + // Setting /TestCaseFilter to the test name, which does not exists in the assembly, so we will have 0 tests executed + arguments = string.Concat(arguments, " /TestCaseFilter:TestNameThatMatchesNoTestInTheAssembly"); - // set FailWhenNoTestsFound to true - arguments = string.Concat(arguments, " -- RunConfiguration.FailWhenNoTestsFound=true"); + arguments = string.Concat(arguments, " -- RunConfiguration.TreatNoTestsAsError=true"); this.InvokeVsTest(arguments); this.ExitCodeEquals(1); @@ -286,19 +285,18 @@ public void ExitCodeShouldReturnOneWhenFailWhenNoTestsFoundParameterSetToTrueAnd [TestMethod] [NetFullTargetFrameworkDataSource] - public void ExitCodeShouldReturnZeroWhenFailWhenNoTestsFoundParameterSetToTrueAndNoTestAvailableWithFilter(RunnerInfo runnerInfo) + public void ExitCodeShouldReturnZeroWhenTreatNoTestsAsErrorParameterSetToFalseAndNoTestMatchesFilter(RunnerInfo runnerInfo) { SetTestEnvironment(this.testEnvironment, runnerInfo); var assemblyPaths = this.BuildMultipleAssemblyPath("SimpleTestProject2.dll").Trim('\"'); var arguments = PrepareArguments(assemblyPaths, this.GetTestAdapterPath(), string.Empty, this.FrameworkArgValue, runnerInfo.InIsolationValue); - - // Setting /TestCaseFilter to random test name, which does not exists - arguments = string.Concat(arguments, " /TestCaseFilter:SomeRandomTestName"); - // set FailWhenNoTestsFound to true - arguments = string.Concat(arguments, " -- RunConfiguration.FailWhenNoTestsFound=false"); + // Setting /TestCaseFilter to the test name, which does not exists in the assembly, so we will have 0 tests executed + arguments = string.Concat(arguments, " /TestCaseFilter:TestNameThatMatchesNoTestInTheAssembly"); + + arguments = string.Concat(arguments, " -- RunConfiguration.TreatNoTestsAsError=false"); this.InvokeVsTest(arguments); this.ExitCodeEquals(0); @@ -306,7 +304,7 @@ public void ExitCodeShouldReturnZeroWhenFailWhenNoTestsFoundParameterSetToTrueAn [TestMethod] [NetFullTargetFrameworkDataSource] - public void ExitCodeShouldNotDependOnFailWhenNoTestsFoundTrueValueWhenTestsAreAvailable(RunnerInfo runnerInfo) + public void ExitCodeShouldNotDependOnTreatNoTestsAsErrorTrueValueWhenThereAreAnyTestsToRun(RunnerInfo runnerInfo) { SetTestEnvironment(this.testEnvironment, runnerInfo); @@ -314,16 +312,16 @@ public void ExitCodeShouldNotDependOnFailWhenNoTestsFoundTrueValueWhenTestsAreAv var arguments = PrepareArguments(assemblyPaths, this.GetTestAdapterPath(), string.Empty, this.FrameworkArgValue, runnerInfo.InIsolationValue); - // set FailWhenNoTestsFound to true - arguments = string.Concat(arguments, " -- RunConfiguration.FailWhenNoTestsFound=true"); + arguments = string.Concat(arguments, " -- RunConfiguration.TreatNoTestsAsError=true"); this.InvokeVsTest(arguments); + // Returning 1 because of failing test in test assembly (SimpleTestProject2.dll) this.ExitCodeEquals(1); } [TestMethod] [NetFullTargetFrameworkDataSource] - public void ExitCodeShouldNotDependOnFailWhenNoTestsFoundFalseValueWhenTestsAreAvailable(RunnerInfo runnerInfo) + public void ExitCodeShouldNotDependOnFailTreatNoTestsAsErrorFalseValueWhenTestsAreAvailable(RunnerInfo runnerInfo) { SetTestEnvironment(this.testEnvironment, runnerInfo); @@ -331,10 +329,10 @@ public void ExitCodeShouldNotDependOnFailWhenNoTestsFoundFalseValueWhenTestsAreA var arguments = PrepareArguments(assemblyPaths, this.GetTestAdapterPath(), string.Empty, this.FrameworkArgValue, runnerInfo.InIsolationValue); - // set FailWhenNoTestsFound to true - arguments = string.Concat(arguments, " -- RunConfiguration.FailWhenNoTestsFound=true"); + arguments = string.Concat(arguments, " -- RunConfiguration.TreatNoTestsAsError=false"); this.InvokeVsTest(arguments); + // Returning 1 because of failing test in test assembly (SimpleTestProject2.dll) this.ExitCodeEquals(1); } } From 59c23273d086ddf7695d8b1d8ebbfcc5aa1edde2 Mon Sep 17 00:00:00 2001 From: Sanan Yuzbashiyev Date: Tue, 3 Nov 2020 11:28:30 +0100 Subject: [PATCH 14/14] Changing the name of the test --- test/Microsoft.TestPlatform.AcceptanceTests/ExecutionTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Microsoft.TestPlatform.AcceptanceTests/ExecutionTests.cs b/test/Microsoft.TestPlatform.AcceptanceTests/ExecutionTests.cs index 8f356095e4..919437f0db 100644 --- a/test/Microsoft.TestPlatform.AcceptanceTests/ExecutionTests.cs +++ b/test/Microsoft.TestPlatform.AcceptanceTests/ExecutionTests.cs @@ -321,7 +321,7 @@ public void ExitCodeShouldNotDependOnTreatNoTestsAsErrorTrueValueWhenThereAreAny [TestMethod] [NetFullTargetFrameworkDataSource] - public void ExitCodeShouldNotDependOnFailTreatNoTestsAsErrorFalseValueWhenTestsAreAvailable(RunnerInfo runnerInfo) + public void ExitCodeShouldNotDependOnFailTreatNoTestsAsErrorFalseValueWhenThereAreAnyTestsToRun(RunnerInfo runnerInfo) { SetTestEnvironment(this.testEnvironment, runnerInfo);