从套件中的 testNG 运行一项测试 [英] Run one test from testNG within suite
本文介绍了从套件中的 testNG 运行一项测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的 test.xml 文件如下
My test.xml file is as below
<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>
我尝试使用命令行 java org.testng TestNG test.xml -testname testname2
来运行第二个类.但是,它运行了两个测试.
I try to use command line java org.testng TestNG test.xml -testname testname2
to just run the second class. however, it run both of the tests.
如何解决这个问题?
谢谢
推荐答案
下面是从命令提示符执行 testng.xml 中的 requited 测试的命令
below is command to execute requited tests from testng.xml from command prompt
java -cp ".\bin;.\lib\*;" org.testng.TestNG testng.xml -testnames Test1
我希望你使用了 -testname 来调用默认套件.
i hope you used -testname which invokes defult suite.
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
谢谢,壁画
这篇关于从套件中的 testNG 运行一项测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文