简体   繁体   中英

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

xml file will be like as given below.

<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

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

Note: Each class has 4+ test methods available.

In @Test annotation you can pass attribute invocationCount with value of number of time you require to execute.

In xml you cannot implement this type of functionality.

After that you can see number of time your test executed which you have provided as argument in @Test annotation.

for example,

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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