简体   繁体   English

TestNG Xml文件:我想用不同的参数多次运行同一个类

[英]TestNG Xml file:I want to run same class for multiple time with different parameters

xml file will be like as given below. xml文件将如下所示。

<suite name="Selenium Test Suite">
    <parameter name="Param1" value="User1" />
    <test name="Selenium Test Suite">
        <classes>
            <class name="com.exterro.fusion.selenium.Testclass" />  
        </classes>
    </test>
    <parameter name="Param2" value="User2" />
    <test name="Selenium Test Suite2">
        <classes>
             <class name="com.exterro.fusion.selenium.Testclass" />  
        </classes>
    </test>
</suite>

for example i have 8 test means i will copy and write 8 times of below codes in xml 例如,我有8个测试手段,我将在xml中复制和写入8次以下代码

<parameter name="Param2" value="User2" />
<test name="Selenium Test Suite2">
     <classes>
        <class name="com.exterro.fusion.selenium.Test" />  
     </classes>
</test>

In case i have 25 types of test means what will do? 如果我有25种类型的测试手段会做什么?

Note: Each class has 4+ test methods available. 注意:每个类都有4种以上的测试方法。

In @Test annotation you can pass attribute invocationCount with value of number of time you require to execute. @Test注释中,您可以传递属性invocationCount ,其值为您需要执行的时间值。

In xml you cannot implement this type of functionality. 在xml中,您无法实现此类功能。

After that you can see number of time your test executed which you have provided as argument in @Test annotation. 之后,您可以看到您在@Test注释中作为参数提供的测试执行时间。

for example, 例如,

@Test(invocationCount = 8)
public void testTest() {
  // For test parameters you can use data provider class.
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM