* @param args The command line arguments.
*/
public static void main(String[] args)
{
// Use the command line parser to evaluate the command line.
CommandLineParser commandLine =
new CommandLineParser(
new String[][]
{
{ "w", "The number of milliseconds between invocations of test cases.", "ms", "false" },
{ "c", "The number of tests to run concurrently.", "num", "false", MathUtils.SEQUENCE_REGEXP },
{ "r", "The number of times to repeat each test.", "num", "false" },
{ "d", "The length of time to run the tests for.", "duration", "false", MathUtils.DURATION_REGEXP },
{ "f", "The maximum rate to call the tests at.", "frequency", "false", "^([1-9][0-9]*)/([1-9][0-9]*)$" },
{ "s", "The size parameter to run tests with.", "size", "false", MathUtils.SEQUENCE_REGEXP },
{ "t", "The name of the test case to execute.", "name", "false" },
{ "o", "The name of the directory to output test timings to.", "dir", "false" },
{ "n", "A name for this test run, used to name the output file.", "name", "true" },
{
"X:decorators", "A list of additional test decorators to wrap the tests in.",
"\"class.name[:class.name]*\"", "false"
},
{ "1", "Test class.", "class", "true" },
{ "-csv", "Output test results in CSV format.", null, "false" },
{ "-xml", "Output test results in XML format.", null, "false" }
});
// Capture the command line arguments or display errors and correct usage and then exit.
ParsedProperties options = null;
try
{
options = new ParsedProperties(commandLine.parseCommandLine(args));
}
catch (IllegalArgumentException e)
{
System.out.println(commandLine.getErrors());
System.out.println(commandLine.getUsage());
System.exit(FAILURE_EXIT);
}
// Extract the command line options.
Integer delay = options.getPropertyAsInteger("w");
String threadsString = options.getProperty("c");
Integer repetitions = options.getPropertyAsInteger("r");
String durationString = options.getProperty("d");
String paramsString = options.getProperty("s");
String testCaseName = options.getProperty("t");
String reportDir = options.getProperty("o");
String testRunName = options.getProperty("n");
String decorators = options.getProperty("X:decorators");
String testClassName = options.getProperty("1");
boolean csvResults = options.getPropertyAsBoolean("-csv");
boolean xmlResults = options.getPropertyAsBoolean("-xml");
int[] threads = (threadsString == null) ? null : MathUtils.parseSequence(threadsString);
int[] params = (paramsString == null) ? null : MathUtils.parseSequence(paramsString);
Long duration = (durationString == null) ? null : MathUtils.parseDuration(durationString);
// The test run name defaults to the test class name unless a value was specified for it.
testRunName = (testRunName == null) ? testClassName : testRunName;
// Add all the command line options and trailing settings to test context properties. Tests may pick up
// overridden values from there, and these values will be logged in the test results, for analysis and
// to make tests repeatable.
commandLine.addTrailingPairsToProperties(TestContextProperties.getInstance());
commandLine.addOptionsToProperties(TestContextProperties.getInstance());
// Create and start the test runner.
try
{
// Create a list of test decorator factories for use specified decorators to be applied.