Localization for the Test command (#4886)

This commit is contained in:
Scott Carlton 2016-12-01 17:15:25 -08:00 committed by Piotr Puszkiewicz
parent ecfd970045
commit 0622068cc9
2 changed files with 74 additions and 27 deletions

View file

@ -0,0 +1,53 @@
namespace Microsoft.DotNet.Tools.Test
{
internal class LocalizableStrings
{
public const string AppFullName = ".NET Test Driver";
public const string AppDescription = "Test Driver for the .NET Platform";
public const string CmdArgProject = "PROJECT";
public const string CmdArgDescription = "The project to test, defaults to the current directory.";
public const string CmdSettingsFile = "SettingsFile";
public const string CmdSettingsDescription = "Settings to use when running tests.";
public const string CmdListTestsDescription = @"Lists discovered tests";
public const string CmdTestCaseFilterExpression = "Expression";
public const string CmdTestCaseFilterDescription = @"Run tests that match the given expression.
Examples:
--testCaseFilter:""Priority = 1""
--testCaseFilter: ""(FullyQualifiedName~Nightly | Name = MyTestMethod)""";
public const string CmdTestAdapterPathDescription = @"Use custom adapters from the given path in the test run.
Example: --testAdapterPath:<pathToCustomAdapters>";
public const string CmdLoggerOption = "LoggerUri/FriendlyName";
public const string CmdLoggerDescription = @"Specify a logger for test results.
Example: --logger:trx";
public const string CmdConfiguration = "configuration";
public const string CmdConfigDescription = @"Configuration under which to build, i.e. Debug/Release";
public const string CmdFramework = "FrameworkVersion";
public const string CmdFrameworkDescription = @"Looks for test binaries for a specific framework";
public const string CmdOutputDir = "OutputDir";
public const string CmdOutputDescription = @"Directory in which to find the binaries to be run";
public const string CmdPathToLogFile = "PathToLogFile";
public const string CmdPathTologFileDescription = @"Enable verbose logs for test platform.
Logs are written to the provided file.";
public const string CmdNoBuildDescription = @"Do not build project before testing.";
}
}

View file

@ -20,8 +20,8 @@ namespace Microsoft.DotNet.Tools.Test
var cmd = new CommandLineApplication(throwOnUnexpectedArg: false) var cmd = new CommandLineApplication(throwOnUnexpectedArg: false)
{ {
Name = "dotnet test", Name = "dotnet test",
FullName = ".NET Test Driver", FullName = LocalizableStrings.AppFullName,
Description = "Test Driver for the .NET Platform" Description = LocalizableStrings.AppDescription
}; };
cmd.AllowArgumentSeparator = true; cmd.AllowArgumentSeparator = true;
@ -29,64 +29,58 @@ namespace Microsoft.DotNet.Tools.Test
cmd.HelpOption("-h|--help"); cmd.HelpOption("-h|--help");
var argRoot = cmd.Argument( var argRoot = cmd.Argument(
"<PROJECT>", $"<{LocalizableStrings.CmdArgProject}>",
"The project to test, defaults to the current directory.", LocalizableStrings.CmdArgDescription,
multipleValues: false); multipleValues: false);
var settingOption = cmd.Option( var settingOption = cmd.Option(
"-s|--settings <SettingsFile>", $"-s|--settings <{LocalizableStrings.CmdSettingsFile}>",
"Settings to use when running tests.", LocalizableStrings.CmdSettingsDescription,
CommandOptionType.SingleValue); CommandOptionType.SingleValue);
var listTestsOption = cmd.Option( var listTestsOption = cmd.Option(
"-lt|--listTests", "-lt|--listTests",
@"Lists discovered tests", LocalizableStrings.CmdListTestsDescription,
CommandOptionType.NoValue); CommandOptionType.NoValue);
var testCaseFilterOption = cmd.Option( var testCaseFilterOption = cmd.Option(
"-tcf|--testCaseFilter <Expression>", $"-tcf|--testCaseFilter <{LocalizableStrings.CmdTestCaseFilterExpression}>",
@"Run tests that match the given expression. LocalizableStrings.CmdTestCaseFilterDescription,
Examples:
--testCaseFilter:""Priority = 1""
--testCaseFilter: ""(FullyQualifiedName~Nightly | Name = MyTestMethod)""",
CommandOptionType.SingleValue); CommandOptionType.SingleValue);
var testAdapterPathOption = cmd.Option( var testAdapterPathOption = cmd.Option(
"-tap|--testAdapterPath", "-tap|--testAdapterPath",
@"Use custom adapters from the given path in the test run. LocalizableStrings.CmdTestAdapterPathDescription,
Example: --testAdapterPath:<pathToCustomAdapters>",
CommandOptionType.SingleValue); CommandOptionType.SingleValue);
var loggerOption = cmd.Option( var loggerOption = cmd.Option(
"-l|--logger <LoggerUri/FriendlyName>", $"-l|--logger <{LocalizableStrings.CmdLoggerOption}>",
@"Specify a logger for test results. LocalizableStrings.CmdLoggerDescription,
Example: --logger:trx",
CommandOptionType.SingleValue); CommandOptionType.SingleValue);
var configurationOption = cmd.Option( var configurationOption = cmd.Option(
"-c|--configuration <configuration>", $"-c|--configuration <{LocalizableStrings.CmdConfiguration}>",
@"Configuration under which to build, i.e. Debug/Release", LocalizableStrings.CmdConfigDescription,
CommandOptionType.SingleValue); CommandOptionType.SingleValue);
var frameworkOption = cmd.Option( var frameworkOption = cmd.Option(
"-f|--framework <FrameworkVersion>", $"-f|--framework <{LocalizableStrings.CmdFramework}>",
@"Looks for test binaries for a specific framework", LocalizableStrings.CmdFrameworkDescription,
CommandOptionType.SingleValue); CommandOptionType.SingleValue);
var outputOption = cmd.Option( var outputOption = cmd.Option(
"-o|--output <OutputDir>", $"-o|--output <{LocalizableStrings.CmdOutputDir}>",
@"Directory in which to find the binaries to be run", LocalizableStrings.CmdOutputDescription,
CommandOptionType.SingleValue); CommandOptionType.SingleValue);
var diagOption = cmd.Option( var diagOption = cmd.Option(
"-d|--diag <PathToLogFile>", $"-d|--diag <{LocalizableStrings.CmdPathToLogFile}>",
@"Enable verbose logs for test platform. LocalizableStrings.CmdPathTologFileDescription,
Logs are written to the provided file.",
CommandOptionType.SingleValue); CommandOptionType.SingleValue);
var noBuildtOption = cmd.Option( var noBuildtOption = cmd.Option(
"--noBuild", "--noBuild",
@"Do not build project before testing.", LocalizableStrings.CmdNoBuildDescription,
CommandOptionType.NoValue); CommandOptionType.NoValue);
CommandOption verbosityOption = MSBuildForwardingApp.AddVerbosityOption(cmd); CommandOption verbosityOption = MSBuildForwardingApp.AddVerbosityOption(cmd);