2016-04-29 87 views
0
內測試

我的test.xml文件如下運行一個從TestNG的套件

<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只運行第二類。但是,它運行兩個測試。

如何解決這個問題?

感謝

+0

您是否使用排除標籤 以外的問題得到答案? –

回答

1

下面是命令從從的testng.xml命令提示符

java -cp ".\bin;.\lib\*;" org.testng.TestNG testng.xml -testnames Test1 

執行報應測試中,我希望你用-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 

謝謝你, 穆拉利

+0

嗨Murali,如果我使用-testnames,在其他方法運行或不運行@BeforeSuite方法。它似乎沒有。 – sspqingda

+0

你能幫助我更多的信息.​​.謝謝 –

1

我們可以用exclude標籤在testng.xml文件,如果我們想跳過的測試用例任何部分的執行。請在下面找到它跳過testname1測試的執行XML文件:

<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> 

希望這有助於。

相關問題