4-Run TestNG
TestNG can be invoked in a different way:
* Command line
* ant
* Eclipse
* IntelliJ's IDEA
1) Command line
Let's say you've added testng to class path, calling TestNG the simplest method:
java org.testng.TestNG testng1.xml [testng2.xml testng3.xml ...]
You must specify at least one XML file that describes the TestNG suite you are trying to test. In addition, the following command-line arguments can be used:
Command line argument list
Option parameter Documentation description
-D Directory Generation report (Test-output)
-sourcedir a semicolon-delimited list of directories with a test source file directory with Javadoc annotations. This option is only valid if you are using the Javadoc type of annotation.
(For example, "Src/test" or "src/test/org/testng/eclipse-plugin;src/test/org/testng/testng").
-testclass a comma-delimited list of classes that can be found in the classpath path. Comma-delimited list of class files (for example, "Org.foo.test1,org.foo.test2").
-groups a comma-delimited list of groups to run (for example, "Windows,linux,regression").
-excludegroups comma-delimited list of groups that you do not want to include in this run
The Java class that-testrunfactory can find in classpath specifies the runner of the test. This class needs to implement Interface Org.testng.ITestRunnerFactory.
-listener a comma-delimited list of classes that can be found in the classpath path. Specifies the listener of the test. This class needs to implement the interface Org.testng.ITestListener
-parallel methods|tests If specified, sets the default mechanism for using concurrent threads when running tests. If not set, the default mechanism is to not use concurrent threads at all. This setting can be overridden by a suite definition.
-threadcount the number of threads used by default when concurrent test runs to set the default number of threads for concurrent tests. Takes effect only when the concurrency mode is selected (for example, the-parallel option is turned on). This setting can be overridden by a suite definition.
-suitename the default name used by the test suite. Specifies the name of the test suite that is defined on the command line. This option is ignored if the Suite.xml file or source code specifies another different suite name. You can create a suite name with spaces, if you enclose the name in double quotes such as "like this."
-testname the default name used by the test. Specifies the name of the test that is defined on the command line. This option is ignored if the Suite.xml file or source code specifies another different test name. You can create a test name with spaces, if you enclose the name in double quotes such as "like this."
-reporter extended configuration is used to customize report Listenner. Similar to the-listener option, in addition to allowing reporter samples to be configured in JavaBean form.
For example:-reporter com.test.myreporter:methodfilter=*insert*,enablefiltering=true
You can get this document by calling TESTNFG directly without any arguments.