Home | History | Annotate | Download | only in testng
      1 package org.testng;
      2 
      3 import com.beust.jcommander.Parameter;
      4 import com.beust.jcommander.converters.CommaParameterSplitter;
      5 
      6 import org.testng.collections.Lists;
      7 import org.testng.xml.XmlSuite;
      8 
      9 import java.util.ArrayList;
     10 import java.util.List;
     11 
     12 public class CommandLineArgs {
     13 
     14   @Parameter(description = "The XML suite files to run")
     15   public List<String> suiteFiles = Lists.newArrayList();
     16 
     17   public static final String LOG = "-log";
     18   public static final String VERBOSE = "-verbose";
     19   @Parameter(names = { LOG, VERBOSE }, description = "Level of verbosity")
     20   public Integer verbose;
     21 
     22   public static final String GROUPS = "-groups";
     23   @Parameter(names = GROUPS, description = "Comma-separated list of group names to be run")
     24   public String groups;
     25 
     26   public static final String EXCLUDED_GROUPS = "-excludegroups";
     27   @Parameter(names = EXCLUDED_GROUPS, description ="Comma-separated list of group names to "
     28       + " exclude")
     29   public String excludedGroups;
     30 
     31   public static final String OUTPUT_DIRECTORY = "-d";
     32   @Parameter(names = OUTPUT_DIRECTORY, description ="Output directory")
     33   public String outputDirectory;
     34 
     35   public static final String JUNIT = "-junit";
     36   @Parameter(names = JUNIT, description ="JUnit mode")
     37   public Boolean junit = Boolean.FALSE;
     38 
     39   public static final String MIXED = "-mixed";
     40   @Parameter(names = MIXED, description ="Mixed mode - autodetect the type of current test" +
     41       " and run it with appropriate runner")
     42   public Boolean mixed = Boolean.FALSE;
     43 
     44   public static final String LISTENER = "-listener";
     45   @Parameter(names = LISTENER, description = "List of .class files or list of class names" +
     46       " implementing ITestListener or ISuiteListener")
     47   public String listener;
     48 
     49   public static final String METHOD_SELECTORS = "-methodselectors";
     50   @Parameter(names = METHOD_SELECTORS, description = "List of .class files or list of class " +
     51         "names implementing IMethodSelector")
     52   public String methodSelectors;
     53 
     54   public static final String OBJECT_FACTORY = "-objectfactory";
     55   @Parameter(names = OBJECT_FACTORY, description = "List of .class files or list of class " +
     56         "names implementing ITestRunnerFactory")
     57   public String objectFactory;
     58 
     59   public static final String PARALLEL= "-parallel";
     60   @Parameter(names = PARALLEL, description = "Parallel mode (methods, tests or classes)")
     61   public XmlSuite.ParallelMode parallelMode;
     62 
     63   public static final String CONFIG_FAILURE_POLICY = "-configfailurepolicy";
     64   @Parameter(names = CONFIG_FAILURE_POLICY , description = "Configuration failure policy (skip or continue)")
     65   public String configFailurePolicy;
     66 
     67   public static final String THREAD_COUNT = "-threadcount";
     68   @Parameter(names = THREAD_COUNT, description = "Number of threads to use when running tests " +
     69       "in parallel")
     70   public Integer threadCount;
     71 
     72   public static final String DATA_PROVIDER_THREAD_COUNT = "-dataproviderthreadcount";
     73   @Parameter(names = DATA_PROVIDER_THREAD_COUNT, description = "Number of threads to use when " +
     74       "running data providers")
     75   public Integer dataProviderThreadCount;
     76 
     77   public static final String SUITE_NAME = "-suitename";
     78   @Parameter(names = SUITE_NAME, description = "Default name of test suite, if not specified " +
     79       "in suite definition file or source code")
     80   public String suiteName;
     81 
     82   public static final String TEST_NAME = "-testname";
     83   @Parameter(names = TEST_NAME, description = "Default name of test, if not specified in suite" +
     84       "definition file or source code")
     85   public String testName;
     86 
     87   public static final String REPORTER = "-reporter";
     88   @Parameter(names = REPORTER, description = "Extended configuration for custom report listener")
     89   public String reporter;
     90 
     91   public static final String USE_DEFAULT_LISTENERS = "-usedefaultlisteners";
     92   @Parameter(names = USE_DEFAULT_LISTENERS, description = "Whether to use the default listeners")
     93   public String useDefaultListeners = "true";
     94 
     95   public static final String SKIP_FAILED_INVOCATION_COUNTS = "-skipfailedinvocationcounts";
     96   @Parameter(names = SKIP_FAILED_INVOCATION_COUNTS, hidden = true)
     97   public Boolean skipFailedInvocationCounts;
     98 
     99   public static final String TEST_CLASS = "-testclass";
    100   @Parameter(names = TEST_CLASS, description = "The list of test classes")
    101   public String testClass;
    102 
    103   public static final String TEST_NAMES = "-testnames";
    104   @Parameter(names = TEST_NAMES, description = "The list of test names to run")
    105   public String testNames;
    106 
    107   public static final String TEST_JAR = "-testjar";
    108   @Parameter(names = TEST_JAR, description = "A jar file containing the tests")
    109   public String testJar;
    110 
    111   public static final String XML_PATH_IN_JAR = "-xmlpathinjar";
    112   public static final String XML_PATH_IN_JAR_DEFAULT = "testng.xml";
    113   @Parameter(names = XML_PATH_IN_JAR, description = "The full path to the xml file inside the jar file (only valid if -testjar was specified)")
    114   public String xmlPathInJar = XML_PATH_IN_JAR_DEFAULT;
    115 
    116   public static final String TEST_RUNNER_FACTORY = "-testrunfactory";
    117   @Parameter(names = { TEST_RUNNER_FACTORY, "-testRunFactory" },
    118       description = "The factory used to create tests")
    119   public String testRunnerFactory;
    120 
    121   public static final String PORT = "-port";
    122   @Parameter(names = PORT, description = "The port")
    123   public Integer port;
    124 
    125   public static final String HOST = "-host";
    126   @Parameter(names = HOST, description = "The host", hidden = true)
    127   public String host;
    128 
    129   public static final String MASTER = "-master";
    130   @Parameter(names = MASTER, description = "Host where the master is", hidden = true)
    131   public String master;
    132 
    133   public static final String SLAVE = "-slave";
    134   @Parameter(names = SLAVE, description = "Host where the slave is", hidden = true)
    135   public String slave;
    136 
    137   public static final String METHODS = "-methods";
    138   @Parameter(names = METHODS, description = "Comma separated of test methods",
    139       splitter = CommaParameterSplitter.class)
    140   public List<String> commandLineMethods = new ArrayList<>();
    141 
    142   public static final String SUITE_THREAD_POOL_SIZE = "-suitethreadpoolsize";
    143   public static final Integer SUITE_THREAD_POOL_SIZE_DEFAULT = 1;
    144   @Parameter(names = SUITE_THREAD_POOL_SIZE, description = "Size of the thread pool to use"
    145         + " to run suites")
    146   public Integer suiteThreadPoolSize = SUITE_THREAD_POOL_SIZE_DEFAULT;
    147 
    148   public static final String RANDOMIZE_SUITES = "-randomizesuites";
    149   @Parameter(names = RANDOMIZE_SUITES, hidden = true,
    150       description = "Whether to run suites in same order as specified in XML or not")
    151   public Boolean randomizeSuites = Boolean.FALSE;
    152 
    153   public static final String DEBUG = "-debug";
    154   @Parameter(names = DEBUG, hidden = true, description = "Used to debug TestNG")
    155   public Boolean debug = Boolean.FALSE;
    156 
    157 }
    158