diff --git a/src/Platform/Microsoft.Testing.Platform/CommandLine/PlatformCommandLineProvider.cs b/src/Platform/Microsoft.Testing.Platform/CommandLine/PlatformCommandLineProvider.cs index 34685687d1..ba26ab2f22 100644 --- a/src/Platform/Microsoft.Testing.Platform/CommandLine/PlatformCommandLineProvider.cs +++ b/src/Platform/Microsoft.Testing.Platform/CommandLine/PlatformCommandLineProvider.cs @@ -31,6 +31,7 @@ internal sealed class PlatformCommandLineProvider : ICommandLineOptionsProvider public const string MinimumExpectedTestsOptionKey = "minimum-expected-tests"; public const string TestHostControllerPIDOptionKey = "internal-testhostcontroller-pid"; public const string ExitOnProcessExitOptionKey = "exit-on-process-exit"; + public const string ConfigFileOptionKey = "config-file"; public const string ServerOptionKey = "server"; public const string ClientPortOptionKey = "client-port"; @@ -59,6 +60,7 @@ internal sealed class PlatformCommandLineProvider : ICommandLineOptionsProvider new(DiscoverTestsOptionKey, PlatformResources.PlatformCommandLineDiscoverTestsOptionDescription, ArgumentArity.Zero, false, isBuiltIn: true), new(IgnoreExitCodeOptionKey, PlatformResources.PlatformCommandLineIgnoreExitCodeOptionDescription, ArgumentArity.ExactlyOne, false, isBuiltIn: true), new(ExitOnProcessExitOptionKey, PlatformResources.PlatformCommandLineExitOnProcessExitOptionDescription, ArgumentArity.ExactlyOne, false, isBuiltIn: true), + new(ConfigFileOptionKey, PlatformResources.PlatformCommandLineConfigFileOptionDescription, ArgumentArity.ExactlyOne, false, isBuiltIn: true), // Hidden options new(HelpOptionQuestionMark, PlatformResources.PlatformCommandLineHelpOptionDescription, ArgumentArity.Zero, true, isBuiltIn: true), @@ -120,6 +122,25 @@ public Task ValidateOptionArgumentsAsync(CommandLineOption com } } + if (commandOption.Name == ConfigFileOptionKey) + { + string arg = arguments[0]; + if (!File.Exists(arg)) + { + try + { + // Get the full path for better error messages. + // As this is only for the purpose of throwing an exception, ignore any exceptions during the GetFullPath call. + arg = Path.GetFullPath(arg); + } + catch + { + } + + return ValidationResult.InvalidTask(string.Format(CultureInfo.InvariantCulture, PlatformResources.ConfigurationFileNotFound, arg)); + } + } + // Now validate the minimum expected tests option return IsMinimumExpectedTestsOptionValidAsync(commandOption, arguments); } diff --git a/src/Platform/Microsoft.Testing.Platform/Configurations/JsonConfigurationProvider.cs b/src/Platform/Microsoft.Testing.Platform/Configurations/JsonConfigurationProvider.cs index 68b80c53a5..5857586520 100644 --- a/src/Platform/Microsoft.Testing.Platform/Configurations/JsonConfigurationProvider.cs +++ b/src/Platform/Microsoft.Testing.Platform/Configurations/JsonConfigurationProvider.cs @@ -1,18 +1,27 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. +using System.Globalization; + +using Microsoft.Testing.Platform.CommandLine; using Microsoft.Testing.Platform.Helpers; using Microsoft.Testing.Platform.Logging; +using Microsoft.Testing.Platform.Resources; using Microsoft.Testing.Platform.Services; namespace Microsoft.Testing.Platform.Configurations; internal sealed partial class JsonConfigurationSource { - internal sealed class JsonConfigurationProvider(ITestApplicationModuleInfo testApplicationModuleInfo, IFileSystem fileSystem, ILogger? logger) : IConfigurationProvider + internal sealed class JsonConfigurationProvider( + ITestApplicationModuleInfo testApplicationModuleInfo, + IFileSystem fileSystem, + CommandLineParseResult commandLineParseResult, + ILogger? logger) : IConfigurationProvider { private readonly ITestApplicationModuleInfo _testApplicationModuleInfo = testApplicationModuleInfo; private readonly IFileSystem _fileSystem = fileSystem; + private readonly CommandLineParseResult _commandLineParseResult = commandLineParseResult; private readonly ILogger? _logger = logger; private Dictionary? _propertyToAllChildren; private Dictionary? _singleValueData; @@ -29,13 +38,35 @@ private async Task LogInformationAsync(string message) public async Task LoadAsync() { - string configFileName = $"{Path.Combine( - Path.GetDirectoryName(_testApplicationModuleInfo.GetCurrentTestApplicationFullPath())!, - Path.GetFileNameWithoutExtension(_testApplicationModuleInfo.GetCurrentTestApplicationFullPath()))}{PlatformConfigurationConstants.PlatformConfigSuffixFileName}"; - if (!_fileSystem.Exists(configFileName)) + string configFileName; + if (_commandLineParseResult.TryGetOptionArgumentList(PlatformCommandLineProvider.ConfigFileOptionKey, out string[]? configOptions)) { - await LogInformationAsync($"Config file '{configFileName}' not found."); - return; + configFileName = configOptions[0]; + if (!_fileSystem.Exists(configFileName)) + { + try + { + // Get the full path for better error messages. + // As this is only for the purpose of throwing an exception, ignore any exceptions during the GetFullPath call. + configFileName = Path.GetFullPath(configFileName); + } + catch + { + } + + throw new FileNotFoundException(string.Format(CultureInfo.InvariantCulture, PlatformResources.ConfigurationFileNotFound, configFileName), configFileName); + } + } + else + { + configFileName = $"{Path.Combine( + Path.GetDirectoryName(_testApplicationModuleInfo.GetCurrentTestApplicationFullPath())!, + Path.GetFileNameWithoutExtension(_testApplicationModuleInfo.GetCurrentTestApplicationFullPath()))}{PlatformConfigurationConstants.PlatformConfigSuffixFileName}"; + + if (!_fileSystem.Exists(configFileName)) + { + return; + } } await LogInformationAsync($"Config file '{configFileName}' loaded."); diff --git a/src/Platform/Microsoft.Testing.Platform/Configurations/JsonConfigurationSource.cs b/src/Platform/Microsoft.Testing.Platform/Configurations/JsonConfigurationSource.cs index 470ab1712b..3855c806e8 100644 --- a/src/Platform/Microsoft.Testing.Platform/Configurations/JsonConfigurationSource.cs +++ b/src/Platform/Microsoft.Testing.Platform/Configurations/JsonConfigurationSource.cs @@ -34,5 +34,5 @@ internal sealed partial class JsonConfigurationSource(ITestApplicationModuleInfo public Task IsEnabledAsync() => Task.FromResult(true); public Task BuildAsync(CommandLineParseResult commandLineParseResult) - => Task.FromResult((IConfigurationProvider)new JsonConfigurationProvider(_testApplicationModuleInfo, _fileSystem, _fileLoggerProvider?.CreateLogger(typeof(JsonConfigurationProvider).ToString()))); + => Task.FromResult((IConfigurationProvider)new JsonConfigurationProvider(_testApplicationModuleInfo, _fileSystem, commandLineParseResult, _fileLoggerProvider?.CreateLogger(typeof(JsonConfigurationProvider).ToString()))); } diff --git a/src/Platform/Microsoft.Testing.Platform/Resources/PlatformResources.resx b/src/Platform/Microsoft.Testing.Platform/Resources/PlatformResources.resx index 51d20861e7..5bd7f79c1a 100644 --- a/src/Platform/Microsoft.Testing.Platform/Resources/PlatformResources.resx +++ b/src/Platform/Microsoft.Testing.Platform/Resources/PlatformResources.resx @@ -665,4 +665,10 @@ Takes one argument as string in the format <value>[h|m|s] where 'value' is Specifies the minimum number of tests that are expected to run. - \ No newline at end of file + + Specifies a testconfig.json file. + + + The configuration file '{0}' specified with '--config-file' could not be found. + + diff --git a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.cs.xlf b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.cs.xlf index 59c6383447..8db997eddd 100644 --- a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.cs.xlf +++ b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.cs.xlf @@ -157,6 +157,11 @@ Už je zaregistrovaná stejná instance CompositeExtensonFactory. + + The configuration file '{0}' specified with '--config-file' could not be found. + The configuration file '{0}' specified with '--config-file' could not be found. + + Could not find the default json configuration Nepovedlo se najít výchozí konfiguraci json. @@ -416,6 +421,11 @@ Zadejte port klienta. + + Specifies a testconfig.json file. + Specifies a testconfig.json file. + + Force the built-in file logger to write the log synchronously. Useful for scenario where you don't want to lose any log (i.e. in case of crash). diff --git a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.de.xlf b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.de.xlf index 93010da43a..154d7a643b 100644 --- a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.de.xlf +++ b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.de.xlf @@ -157,6 +157,11 @@ Die gleiche Instanz von "CompositeExtensonFactory" ist bereits registriert + + The configuration file '{0}' specified with '--config-file' could not be found. + The configuration file '{0}' specified with '--config-file' could not be found. + + Could not find the default json configuration Die standardmäßige JSON-Konfiguration wurde nicht gefunden. @@ -416,6 +421,11 @@ Geben Sie den Port des Clients an. + + Specifies a testconfig.json file. + Specifies a testconfig.json file. + + Force the built-in file logger to write the log synchronously. Useful for scenario where you don't want to lose any log (i.e. in case of crash). diff --git a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.es.xlf b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.es.xlf index 91955cb0c2..ffc6cc0328 100644 --- a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.es.xlf +++ b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.es.xlf @@ -157,6 +157,11 @@ La misma instancia de "CompositeExtensonFactory" ya está registrada + + The configuration file '{0}' specified with '--config-file' could not be found. + The configuration file '{0}' specified with '--config-file' could not be found. + + Could not find the default json configuration No se pudo encontrar la configuración json predeterminada @@ -416,6 +421,11 @@ Especifique el puerto del cliente. + + Specifies a testconfig.json file. + Specifies a testconfig.json file. + + Force the built-in file logger to write the log synchronously. Useful for scenario where you don't want to lose any log (i.e. in case of crash). diff --git a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.fr.xlf b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.fr.xlf index a52c16c4c7..d312b88920 100644 --- a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.fr.xlf +++ b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.fr.xlf @@ -157,6 +157,11 @@ La même instance de « CompositeExtensonFactory » est déjà inscrite + + The configuration file '{0}' specified with '--config-file' could not be found. + The configuration file '{0}' specified with '--config-file' could not be found. + + Could not find the default json configuration Configuration JSON par défaut introuvable @@ -416,6 +421,11 @@ Spécifier le port du client. + + Specifies a testconfig.json file. + Specifies a testconfig.json file. + + Force the built-in file logger to write the log synchronously. Useful for scenario where you don't want to lose any log (i.e. in case of crash). diff --git a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.it.xlf b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.it.xlf index ffc131d874..b87e60db7c 100644 --- a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.it.xlf +++ b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.it.xlf @@ -157,6 +157,11 @@ La stessa istanza di 'CompositeExtensonFactory' è già registrata + + The configuration file '{0}' specified with '--config-file' could not be found. + The configuration file '{0}' specified with '--config-file' could not be found. + + Could not find the default json configuration Non è stato possibile trovare la configurazione JSON predefinita @@ -416,6 +421,11 @@ Specifica la porta del client. + + Specifies a testconfig.json file. + Specifies a testconfig.json file. + + Force the built-in file logger to write the log synchronously. Useful for scenario where you don't want to lose any log (i.e. in case of crash). diff --git a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.ja.xlf b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.ja.xlf index 93c55f9f9e..d7e5015d90 100644 --- a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.ja.xlf +++ b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.ja.xlf @@ -157,6 +157,11 @@ 'CompositeExtensonFactory' の同じインスタンスが既に登録されています + + The configuration file '{0}' specified with '--config-file' could not be found. + The configuration file '{0}' specified with '--config-file' could not be found. + + Could not find the default json configuration 既定の JSON 構成が見つかりませんでした @@ -416,6 +421,11 @@ クライアントのポートを指定します。 + + Specifies a testconfig.json file. + Specifies a testconfig.json file. + + Force the built-in file logger to write the log synchronously. Useful for scenario where you don't want to lose any log (i.e. in case of crash). diff --git a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.ko.xlf b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.ko.xlf index 02feafb53a..9c15b13c2d 100644 --- a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.ko.xlf +++ b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.ko.xlf @@ -157,6 +157,11 @@ 동일한 'CompositeExtensonFactory' 인스턴스가 이미 등록됨 + + The configuration file '{0}' specified with '--config-file' could not be found. + The configuration file '{0}' specified with '--config-file' could not be found. + + Could not find the default json configuration 기본 json 구성을 찾을 수 없습니다. @@ -416,6 +421,11 @@ 클라이언트의 포트를 지정합니다. + + Specifies a testconfig.json file. + Specifies a testconfig.json file. + + Force the built-in file logger to write the log synchronously. Useful for scenario where you don't want to lose any log (i.e. in case of crash). diff --git a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.pl.xlf b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.pl.xlf index 63a7e36fe1..b8e6cb922e 100644 --- a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.pl.xlf +++ b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.pl.xlf @@ -157,6 +157,11 @@ To samo wystąpienie elementu „CompositeExtensonFactory” jest już zarejestrowane + + The configuration file '{0}' specified with '--config-file' could not be found. + The configuration file '{0}' specified with '--config-file' could not be found. + + Could not find the default json configuration Nie można odnaleźć domyślnej konfiguracji JSON @@ -416,6 +421,11 @@ Określ port klienta. + + Specifies a testconfig.json file. + Specifies a testconfig.json file. + + Force the built-in file logger to write the log synchronously. Useful for scenario where you don't want to lose any log (i.e. in case of crash). diff --git a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.pt-BR.xlf b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.pt-BR.xlf index a397aabdb9..bcb11fe735 100644 --- a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.pt-BR.xlf +++ b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.pt-BR.xlf @@ -157,6 +157,11 @@ A mesma instância de “CompositeExtensonFactory” já está registrada + + The configuration file '{0}' specified with '--config-file' could not be found. + The configuration file '{0}' specified with '--config-file' could not be found. + + Could not find the default json configuration Não foi possível localizar a configuração padrão do json @@ -416,6 +421,11 @@ Especifique a porta do cliente. + + Specifies a testconfig.json file. + Specifies a testconfig.json file. + + Force the built-in file logger to write the log synchronously. Useful for scenario where you don't want to lose any log (i.e. in case of crash). diff --git a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.ru.xlf b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.ru.xlf index b478eea875..6495697d60 100644 --- a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.ru.xlf +++ b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.ru.xlf @@ -157,6 +157,11 @@ Такой же экземпляр CompositeExtensonFactory уже зарегистрирован + + The configuration file '{0}' specified with '--config-file' could not be found. + The configuration file '{0}' specified with '--config-file' could not be found. + + Could not find the default json configuration Не удалось найти конфигурацию JSON по умолчанию @@ -416,6 +421,11 @@ Укажите порт клиента. + + Specifies a testconfig.json file. + Specifies a testconfig.json file. + + Force the built-in file logger to write the log synchronously. Useful for scenario where you don't want to lose any log (i.e. in case of crash). diff --git a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.tr.xlf b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.tr.xlf index 4d0ad0f21e..207f7a4fd9 100644 --- a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.tr.xlf +++ b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.tr.xlf @@ -157,6 +157,11 @@ Aynı 'CompositeExtensonFactory' örneği zaten kayıtlı + + The configuration file '{0}' specified with '--config-file' could not be found. + The configuration file '{0}' specified with '--config-file' could not be found. + + Could not find the default json configuration Varsayılan JSON yapılandırması bulunamadı @@ -416,6 +421,11 @@ İstemcinin bağlantı noktasını belirtir. + + Specifies a testconfig.json file. + Specifies a testconfig.json file. + + Force the built-in file logger to write the log synchronously. Useful for scenario where you don't want to lose any log (i.e. in case of crash). diff --git a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.zh-Hans.xlf b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.zh-Hans.xlf index 381bffaf18..b90e61c75d 100644 --- a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.zh-Hans.xlf +++ b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.zh-Hans.xlf @@ -157,6 +157,11 @@ “CompositeExtensonFactory”的同一实例已注册 + + The configuration file '{0}' specified with '--config-file' could not be found. + The configuration file '{0}' specified with '--config-file' could not be found. + + Could not find the default json configuration 找不到默认 json 配置 @@ -416,6 +421,11 @@ 指定客户端的端口。 + + Specifies a testconfig.json file. + Specifies a testconfig.json file. + + Force the built-in file logger to write the log synchronously. Useful for scenario where you don't want to lose any log (i.e. in case of crash). diff --git a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.zh-Hant.xlf b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.zh-Hant.xlf index 6a801d838c..b9b18bdbaa 100644 --- a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.zh-Hant.xlf +++ b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.zh-Hant.xlf @@ -157,6 +157,11 @@ 已註冊 'CompositeExtensonFactory' 的同一執行個體 + + The configuration file '{0}' specified with '--config-file' could not be found. + The configuration file '{0}' specified with '--config-file' could not be found. + + Could not find the default json configuration 找不到預設 JSON 設定 @@ -416,6 +421,11 @@ 指定用戶端的連接埠。 + + Specifies a testconfig.json file. + Specifies a testconfig.json file. + + Force the built-in file logger to write the log synchronously. Useful for scenario where you don't want to lose any log (i.e. in case of crash). diff --git a/test/IntegrationTests/MSTest.Acceptance.IntegrationTests/ConfigurationSettingsTests.cs b/test/IntegrationTests/MSTest.Acceptance.IntegrationTests/ConfigurationSettingsTests.cs index 4e2e71f877..1ff51d33a8 100644 --- a/test/IntegrationTests/MSTest.Acceptance.IntegrationTests/ConfigurationSettingsTests.cs +++ b/test/IntegrationTests/MSTest.Acceptance.IntegrationTests/ConfigurationSettingsTests.cs @@ -57,6 +57,42 @@ public async Task TestConfigJson_WithoutRunSettings_BuildSuccess(string tfm) testHostResult.AssertExitCodeIs(ExitCodes.Success); } + public async Task TestWithConfigFromCommandLineWithMapInconclusiveToFailedIsTrue() + { + var testHost = TestHost.LocateFrom(_testAssetFixture.ProjectPath, TestAssetFixture.ProjectName, TargetFrameworks.NetCurrent.Arguments); + TestHostResult testHostResult = await testHost.ExecuteAsync("--config-file dummyconfigfile_map.json", environmentVariables: new() + { + ["TestWithConfigFromCommandLine"] = "true", + }); + + testHostResult.AssertExitCodeIs(ExitCodes.AtLeastOneTestFailed); + testHostResult.AssertOutputContainsSummary(failed: 1, passed: 1, skipped: 0); + } + + public async Task TestWithConfigFromCommandLineWithMapInconclusiveToFailedIsFalse() + { + var testHost = TestHost.LocateFrom(_testAssetFixture.ProjectPath, TestAssetFixture.ProjectName, TargetFrameworks.NetCurrent.Arguments); + TestHostResult testHostResult = await testHost.ExecuteAsync("--config-file dummyconfigfile_doNotMap.json", environmentVariables: new() + { + ["TestWithConfigFromCommandLine"] = "true", + }); + + testHostResult.AssertExitCodeIs(ExitCodes.Success); + testHostResult.AssertOutputContainsSummary(failed: 0, passed: 1, skipped: 1); + } + + public async Task TestWithConfigFromCommandLineWithNonExistingFile() + { + var testHost = TestHost.LocateFrom(_testAssetFixture.ProjectPath, TestAssetFixture.ProjectName, TargetFrameworks.NetCurrent.Arguments); + TestHostResult testHostResult = await testHost.ExecuteAsync("--config-file dummyconfigfile_not_existing_file.json", environmentVariables: new() + { + ["TestWithConfigFromCommandLine"] = "true", + }); + + testHostResult.AssertStandardErrorContains("FileNotFoundException"); + testHostResult.AssertStandardErrorContains("dummyconfigfile_not_existing_file.json"); + } + [TestFixture(TestFixtureSharingStrategy.PerTestGroup)] public sealed class TestAssetFixture(AcceptanceFixture acceptanceFixture) : TestAssetFixtureBase(acceptanceFixture.NuGetGlobalPackagesFolder) { @@ -127,6 +163,12 @@ public sealed class TestAssetFixture(AcceptanceFixture acceptanceFixture) : Test Always + + Always + + + Always + @@ -143,6 +185,24 @@ public sealed class TestAssetFixture(AcceptanceFixture acceptanceFixture) : Test $AppendSettings$ +#file dummyconfigfile_map.json +{ + "mstest": { + "execution": { + "mapInconclusiveToFailed": true, + }, + } +} + +#file dummyconfigfile_doNotMap.json +{ + "mstest": { + "execution": { + "mapInconclusiveToFailed": false, + }, + } +} + #file $ProjectName$.testconfig.json { "mstest": { @@ -197,6 +257,7 @@ public sealed class TestAssetFixture(AcceptanceFixture acceptanceFixture) : Test #file UnitTest1.cs +using System; using Microsoft.VisualStudio.TestTools.UnitTesting; [TestClass] @@ -206,6 +267,15 @@ public class UnitTest1 public void TestMethod() { } + + [TestMethod] + public void TestWithConfigFromCommandLine() + { + if (Environment.GetEnvironmentVariable("TestWithConfigFromCommandLine") == "true") + { + Assert.Inconclusive("Inconclusive TestWithConfigFromCommandLine"); + } + } } """; } diff --git a/test/IntegrationTests/MSTest.Acceptance.IntegrationTests/HelpInfoTests.cs b/test/IntegrationTests/MSTest.Acceptance.IntegrationTests/HelpInfoTests.cs index 6f5fd33638..8894ffbc2d 100644 --- a/test/IntegrationTests/MSTest.Acceptance.IntegrationTests/HelpInfoTests.cs +++ b/test/IntegrationTests/MSTest.Acceptance.IntegrationTests/HelpInfoTests.cs @@ -31,6 +31,8 @@ public async Task Help_WhenMSTestExtensionRegistered_OutputHelpContentOfRegister Usage {AssetName}* [option providers] [extension option providers] Execute a .NET Test Application. Options: + --config-file + Specifies a testconfig.json file. --diagnostic Enable the diagnostic logging. The default log level is 'Trace'. The file will be written in the output directory with the name log_[yyMMddHHmmssfff].diag diff --git a/test/IntegrationTests/Microsoft.Testing.Platform.Acceptance.IntegrationTests/HelpInfoTests.cs b/test/IntegrationTests/Microsoft.Testing.Platform.Acceptance.IntegrationTests/HelpInfoTests.cs index b44f617897..4292684d6e 100644 --- a/test/IntegrationTests/Microsoft.Testing.Platform.Acceptance.IntegrationTests/HelpInfoTests.cs +++ b/test/IntegrationTests/Microsoft.Testing.Platform.Acceptance.IntegrationTests/HelpInfoTests.cs @@ -27,6 +27,8 @@ .NET Testing Platform v* Usage {TestAssetFixture.NoExtensionAssetName}* [option providers] [extension option providers] Execute a .NET Test Application. Options: + --config-file + Specifies a testconfig.json file. --diagnostic Enable the diagnostic logging. The default log level is 'Trace'. The file will be written in the output directory with the name log_[yyMMddHHmmssfff].diag @@ -150,6 +152,10 @@ .NET Testing Platform v.+ \[.+\] Arity: 1 Hidden: True Description: Specify the port of the client\. + --config-file + Arity: 1 + Hidden: False + Description: Specifies a testconfig\.json file\. --diagnostic Arity: 0 Hidden: False @@ -283,6 +289,8 @@ .NET Testing Platform v* Usage {TestAssetFixture.AllExtensionsAssetName}* [option providers] [extension option providers] Execute a .NET Test Application. Options: + --config-file + Specifies a testconfig.json file. --diagnostic Enable the diagnostic logging. The default log level is 'Trace'. The file will be written in the output directory with the name log_[yyMMddHHmmssfff].diag @@ -418,6 +426,10 @@ .NET Testing Platform v* [*] Arity: 1 Hidden: True Description: Specify the port of the client. + --config-file + Arity: 1 + Hidden: False + Description: Specifies a testconfig.json file. --diagnostic Arity: 0 Hidden: False