[英]Run one test from testNG within suite
My test.xml file is as below 我的test.xml文件如下
<suite name="suitename">
<test name="testname1">
<classes>
<class
name="com.org.test1" />
</classes>
</test>
<test name="testname2">
<classes>
<class
name="com.org.test2" />
</classes>
</test>
I try to use command line java org.testng TestNG test.xml -testname testname2
to just run the second class. 我尝试使用命令行java org.testng TestNG test.xml -testname testname2
来运行第二个类。 however, it run both of the tests. 但是,它运行两个测试。
How to fix that? 如何解决?
Thanks 谢谢
below is command to execute requited tests from testng.xml from command prompt 以下是从命令提示符处执行testng.xml中返回的测试的命令
java -cp ".\bin;.\lib\*;" org.testng.TestNG testng.xml -testnames Test1
i hope you used -testname which invokes defult suite. 我希望您使用了-testname来调用defult套件。
Usage: <main class> [options] The XML suite files to run
Options:
-configfailurepolicy
Configuration failure policy (skip or continue)
-d
Output directory
-dataproviderthreadcount
Number of threads to use when running data providers
-excludegroups
Comma-separated list of group names to exclude
-groups
Comma-separated list of group names to be run
-junit
JUnit mode
Default: false
-listener
List of .class files or list of class names implementing ITestListener or
ISuiteListener
-methods
Comma separated of test methods
Default: []
-methodselectors
List of .class files or list of class names implementing IMethodSelector
-mixed
Mixed mode - autodetect the type of current test and run it with
appropriate runner
Default: false
-objectfactory
List of .class files or list of class names implementing
ITestRunnerFactory
-parallel
Parallel mode (methods, tests or classes)
Possible Values: [tests, methods, classes, instances, none, true, false]
-port
The port
-reporter
Extended configuration for custom report listener
-suitename
Default name of test suite, if not specified in suite definition file or
source code
-suitethreadpoolsize
Size of the thread pool to use to run suites
Default: 1
-testclass
The list of test classes
-testjar
A jar file containing the tests
-testname
Default name of test, if not specified in suitedefinition file or source
code
-testnames
The list of test names to run
-testrunfactory, -testRunFactory
The factory used to create tests
-threadcount
Number of threads to use when running tests in parallel
-usedefaultlisteners
Whether to use the default listeners
Default: true
-log, -verbose
Level of verbosity
-xmlpathinjar
The full path to the xml file inside the jar file (only valid if -testjar
was specified)
Default: testng.xml
Thank You, Murali 谢谢,穆拉利
We can use exclude
tag in testng.xml
file, if we want to skip the execution of any part of test cases. 如果要跳过测试用例的任何部分的执行,可以在testng.xml
文件中使用exclude
标记。 Please find below xml file which skips the execution of testname1
test: 请在下面的xml文件中查找,该文件会跳过testname1
测试的执行:
<suite name="suitename">
<test name="testname1">
<classes>
<exclude
name="com.org.test1" />
</classes>
</test>
<test name="testname2">
<classes>
<class
name="com.org.test2" />
</classes>
</test>
Hope this helps. 希望这可以帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.